Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: mausuv on April 12, 2022, 08:48:24 AM



Title: lattice-attack || how to run without error
Post by: mausuv on April 12, 2022, 08:48:24 AM
any one make video for lattice-attack project

what is data.json :( ,how to make it
how to run without error

this is git https://github.com/bitlogik/lattice-attack

send video my mail :  thinkeasy123@protonmail.com or upload youtube send link please..


Title: Re: lattice-attack || how to run without error
Post by: ABCbits on April 12, 2022, 12:02:08 PM
All question you asked already answered on the repository.

what is data.json :(

From https://github.com/bitlogik/lattice-attack#use (https://github.com/bitlogik/lattice-attack#use), data.json contain some information needed to perform lattice attack.



how to make it

You can either make it manually or use gen_data.py

Code:
python3 gen_data.py

Code:
python3 gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 8 -t MSB -n 50

how to run without error

You need to specify what kind of error you encountered. Have you fulfilled requirements which mentioned at https://github.com/bitlogik/lattice-attack#requirements (https://github.com/bitlogik/lattice-attack#requirements)?


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 16, 2022, 08:56:53 AM

Some problems with install fpylll

Developer using Ubuntu >= 20.04
So try on Ubuntu 20.04

pip install git+https://github.com/bitlogik/lattice-attack
pip install git+https://github.com/fplll/fpylll.git

All command try installs not successful both on os windows and Linux

using conda not successful too
conda install -c conda-forge fpylll

all methods include update apt too

sudo add-apt-repository universe
sudo apt update
sudo apt install python3-fpylll

pip install Cython

all fail


Title: Re: lattice-attack || how to run without error
Post by: ABCbits on April 16, 2022, 12:22:41 PM

Some problems with install fpylll

Developer using Ubuntu >= 20.04
So try on Ubuntu 20.04

pip install git+https://github.com/bitlogik/lattice-attack
pip install git+https://github.com/fplll/fpylll.git

All command try installs not successful both on os windows and Linux

using conda not successful too
conda install -c conda-forge fpylll

all methods include update apt too

sudo add-apt-repository universe
sudo apt update
sudo apt install python3-fpylll

pip install Cython

all fail


There might be problem with your Ubuntu 20.04 or library's setup.py. I tried it on Debian 11 (inside VM) and could run the library without any problem.

Code:
git clone https://github.com/bitlogik/lattice-attack
cd lattice-attack/
sudo apt install python3-cryptography python3-fpylll
python3 gen_data.py # generate example data
python3 lattice_attack.py -f data.json # perform attack with example data

This is the output.

Code:
 ----- Lattice ECDSA Attack ----- 
Loading data from file data.json
Running with 6 bits of k (LSB)
Starting recovery attack (curve SECP256K1)
Constructing matrix
Solving matrix ...
LLL reduction
Key found \o/
0xb75d59be7755c7af999687b769aeac541422ace964eb92d00f1c9a8017b1b7f9


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 16, 2022, 01:28:10 PM

There might be problem with your Ubuntu 20.04 or library's setup.py. I tried it on Debian 11 (inside VM) and could run the library without any problem.
 

Thank you ETFbitcoin

I do a quick test on Debian in WSL2  windows, it is works

I got same result run on Debian no problem


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 16, 2022, 02:42:20 PM

it is just mathematics research and it needs some leaked information to calculate, can not attack ECDSA that no leak data


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 16, 2022, 07:23:19 PM

it is just mathematics research and it needs some leaked information to calculate, can not attack ECDSA that no leak data

Last bit is posible to recovery maybe, or use nonse what probably has msb in zeros....


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 19, 2022, 05:07:10 AM
just random idea
if can modify lattice-attack or cam switch from weak nonce to calculate weak private key may be possible to use solve puzzle 120-160 bit
I mean lattice-attack can solve weak nonce 128 bit and 256 bit private key
if can modify to change calculate strong nonce but weak private key meybe can use for solve 120 bit puzzle
but 120 bit puzzle have only R and S one set only



Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 19, 2022, 07:13:43 AM
Quote
if can modify lattice-attack or cam switch from weak nonce to calculate weak private key may be possible to use solve puzzle 120-160 bit
It is possible, but there is only one problem: you need two signatures. And you need two random signatures, not just two any signatures. Lattice is not that deterministic, you cannot use N and N-1 as your 120-bit nonce. I tried solving this Taproot testnet puzzle transaction: 448b81b2b3c2c8558d268e4f515ff38eb6367d156babbc3733a14834a5a6e7b0. My conclusion is: even for small keys (like 8-bit key) it is not so deterministic. You need a sufficiently random and weak key, you cannot just use any key.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 19, 2022, 07:50:15 AM
Quote
if can modify lattice-attack or cam switch from weak nonce to calculate weak private key may be possible to use solve puzzle 120-160 bit
It is possible, but there is only one problem: you need two signatures. And you need two random signatures, not just two any signatures. Lattice is not that deterministic, you cannot use N and N-1 as your 120-bit nonce. I tried solving this Taproot testnet puzzle transaction: 448b81b2b3c2c8558d268e4f515ff38eb6367d156babbc3733a14834a5a6e7b0. My conclusion is: even for small keys (like 8-bit key) it is not so deterministic. You need a sufficiently random and weak key, you cannot just use any key.

right it requires two sign for calculate

I would like to try to check weak nonce from key generate
if know private key how to calculate to know nonce in python


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 19, 2022, 08:12:15 AM
Just use your public key as R-value in your signature.
Code:
address=17s2b9ksz5y7abUm92cHwG8jEPCzK3dLnT
pubkey=02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
R=02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
SHA-256("120-bit puzzle")=c43bc2e003908850dda3ff2fec69c3028027260ea7eef98746260eb83abe0a18
SHA-256("garlonicon")=272fc6644fedff1a897d6034bed23f61859e99440ee699033307976590316723
s=(z+rd)/k
sk=z+rd
sk-z=rd
d=(sk-z)/r
d=(s/r)k-(z/r)
d+(z/r)=(s/r)k
Q+(z/r)=(s/r)R
z/r=SHA-256("120-bit puzzle")=c43bc2e003908850dda3ff2fec69c3028027260ea7eef98746260eb83abe0a18
s/r=SHA-256("garlonicon")=272fc6644fedff1a897d6034bed23f61859e99440ee699033307976590316723
R=02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
(s/r)R=02276385F22DF0977507516B945B57AC6A74EFEA22E957098B25BDE461696774A0
Q=(s/r)R-(z/r)
(z/r)*G=0315523C6FD9EBA6DB17B946888CA76AE0D3C2B53AB63901ABCAFA0D0A07552DEE
-(z/r)*G=0215523C6FD9EBA6DB17B946888CA76AE0D3C2B53AB63901ABCAFA0D0A07552DEE
Q=02B77D94ADE49B1FF647E012ACD91CF15A7DA1D553CC386E52D9C42E717FAEA4D0
z=(z/r)*r
r=ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
n=fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
z=2de0c47667be3d8a1a36140df763c4a6243ba04663863d761fa552d8d7791c03
s=(s/r)*r
s=2e92f964982c1337f36ca51cd0ca5cfce0526295a03597cc0ddf72babf55d065
Final signature:
Code:
Q=02B77D94ADE49B1FF647E012ACD91CF15A7DA1D553CC386E52D9C42E717FAEA4D0
z=2de0c47667be3d8a1a36140df763c4a6243ba04663863d761fa552d8d7791c03
r=ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
s=2e92f964982c1337f36ca51cd0ca5cfce0526295a03597cc0ddf72babf55d065

Edit:
Quote
if know private key how to calculate to know nonce in python
Code:
s=(z+rd)/k
sk=z+rd
k=(z+rd)/s
sk-z=rd
d=(sk-z)/r
Final equations:
Code:
k=(z+rd)/s
d=(sk-z)/r
If you know k, you can get d. If you know d, you can get k. It is a pair of connected numbers.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 19, 2022, 04:01:56 PM

Final equations:
Code:
k=(z+rd)/s
d=(sk-z)/r
If you know k, you can get d. If you know d, you can get k. It is a pair of connected numbers.

I try use this calculate puzzle #115 but it now work
Can you help to samplecalculate puzzle #115


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 20, 2022, 05:50:23 PM
Quote
Can you help to samplecalculate puzzle #115
So, let's see:
Code:
address=1NLbHuJebVwUZ1XqDjsAyfTRUPwDQbemfv
pubkey=0248d313b0398d4923cdca73b8cfa6532b91b96703902fc8b32fd438a3b7cd7f55
sig1=3045022100c3f5243089c5fc55cb215bb54d6e94f1fb09820a3e917cf52633ab9a5cea20af02207efcf46cbcad512b19d0b72788f21e63d4ccffb2c21f98638176f7816c87ebd301
der1a=3045022100
r1=c3f5243089c5fc55cb215bb54d6e94f1fb09820a3e917cf52633ab9a5cea20af
der1b=0220
s1=7efcf46cbcad512b19d0b72788f21e63d4ccffb2c21f98638176f7816c87ebd3
sighash1=01
sig2=30440220228e890f24db246b0220b0491c78a6f186dcdcb5a927a3b86ffd3b0b03fe6e2602203b4f5ae90419881143e4185820e63616b92d1f394e9414a89d79bc7b90a1c5d001
der2a=30440220
r2=228e890f24db246b0220b0491c78a6f186dcdcb5a927a3b86ffd3b0b03fe6e26
der2b=0220
s2=3b4f5ae90419881143e4185820e63616b92d1f394e9414a89d79bc7b90a1c5d0
sighash2=01
First signature:
Code:
Q=0248d313b0398d4923cdca73b8cfa6532b91b96703902fc8b32fd438a3b7cd7f55
d=0000000000000000000000000000000000060f4d11574f5deee49961d9609ac6
transaction1=020000000215cda65f1e46982fc082b15c8dbb60985d12a7e60b0c742263608cc9349f3808720000001976a914ea0f2b7576bd098921fce9bfebe37f6383e639a488acfdffffff6441384445a0f426ee689e2532e41fc6947dda41558026b80f5b1dfd7c58455d3f00000000fdffffff01f792da0600000000160014d66c2e960c57e689ffa24142bc94636a54eb2ea669b0090001000000
z1=SHA-256(SHA-256(transaction1))=2294cb823a880052d1513223d3c078f8518e277373d40b43ada4a07afa045159
r1=c3f5243089c5fc55cb215bb54d6e94f1fb09820a3e917cf52633ab9a5cea20af
s1=7efcf46cbcad512b19d0b72788f21e63d4ccffb2c21f98638176f7816c87ebd3
k1=(z1+r1d)/s1
n=fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
r1d=534d2b5e5932693b7dd30266d83afdd17ef2433f4498395c8f95b959fa4ad0ae
z1+r1d=75e1f6e093ba698e4f24348aabfb76c9d0806ab2b86c44a03d3a59d4f44f2207
1/s1=582ac1bddcecd0488fb1cdded830126ef1246df1888b6495c564604613618179
k1=3a974e9b3b1015f5bf711dc34e53fe95dc1ee2183e938e32f3bd34ce7e4b9fad
k1*G=02C3F5243089C5FC55CB215BB54D6E94F1FB09820A3E917CF52633AB9A5CEA20AF
r1=c3f5243089c5fc55cb215bb54d6e94f1fb09820a3e917cf52633ab9a5cea20af
r1=(k1*G).x (valid)
Second signature:
Code:
Q=0248d313b0398d4923cdca73b8cfa6532b91b96703902fc8b32fd438a3b7cd7f55
d=0000000000000000000000000000000000060f4d11574f5deee49961d9609ac6
transaction2=020000000215cda65f1e46982fc082b15c8dbb60985d12a7e60b0c742263608cc9349f38087200000000fdffffff6441384445a0f426ee689e2532e41fc6947dda41558026b80f5b1dfd7c58455d3f0000001976a914ea0f2b7576bd098921fce9bfebe37f6383e639a488acfdffffff01f792da0600000000160014d66c2e960c57e689ffa24142bc94636a54eb2ea669b0090001000000
z2=SHA-256(SHA-256(transaction2))=98399882da0936868e7d21e7c971d8896d0897b99d8c141e6bf679ee829e9835
r2=228e890f24db246b0220b0491c78a6f186dcdcb5a927a3b86ffd3b0b03fe6e26
s2=3b4f5ae90419881143e4185820e63616b92d1f394e9414a89d79bc7b90a1c5d0
k2=(z2+r2d)/s2
n=fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
r2d=bb719705669b86f216fdef762715302bd7afa1e4985b206f5e06ed09121757be
z2+r2d=53ab2f8840a4bd78a57b115df08708b68a095cb7869e94520a2b086ac47faeb2
1/s2=c1c01cfeefcba2cc824751307b5964e292f602cc05dfa8f6bc359850dd726a6d
k2=0656c9a7c7bb58c5b632cb88ac6a42d7e224f3595077e100f10c0d72622612fc
k2*G=02228E890F24DB246B0220B0491C78A6F186DCDCB5A927A3B86FFD3B0B03FE6E26
r2=228e890f24db246b0220b0491c78a6f186dcdcb5a927a3b86ffd3b0b03fe6e26
r2=(k2*G).x (valid)


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 21, 2022, 05:43:22 AM

So, let's see:
 
First signature:
 
Second signature:
 

Thank you garlonicon
I try to understand math (still stuck with calculate by manual step by step)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 21, 2022, 08:25:16 PM

So, let's see:
 
First signature:
 
Second signature:
 

Thank you garlonicon
I try to understand math (still stuck with calculate by manual step by step)

R,s,z   is only for outgoing transaction !!!


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 22, 2022, 03:51:52 AM
Quote
R,s,z   is only for outgoing transaction !!!
Yes. But you can always use fake outgoing transaction and choose some z-value, where you don't know any matching transaction. For some attacks, this approach is also useful, even if you don't know any transaction that can use your signature. In lattice attacks, you can use any z-value, you don't care about transactions, because restoring keys is the only thing you can do in such attack, so fake z-value is also useful.


Title: Re: lattice-attack || how to run without error
Post by: litecoin_messiah on April 22, 2022, 05:45:09 PM
don't we use secp256k1 this is r1


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 22, 2022, 07:09:26 PM
Quote
R,s,z   is only for outgoing transaction !!!
Yes. But you can always use fake outgoing transaction and choose some z-value, where you don't know any matching transaction. For some attacks, this approach is also useful, even if you don't know any transaction that can use your signature. In lattice attacks, you can use any z-value, you don't care about transactions, because restoring keys is the only thing you can do in such attack, so fake z-value is also useful.


Realy ? Generate someonevfakecrsz please forvwalid bupkey, and for ex valid s... For crack aftervthis sighnatures ? Original rsz is 99% imposible to crack because different lenght if r,s,z - from x...to ..y for 1 pubkey etc...


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 22, 2022, 07:32:47 PM
Quote
Realy ? Generate someonevfakecrsz please forvwalid bupkey, and for ex valid s...
No problem. There are fake r,s,z values for the public key from the Genesis Block:
Quote
Code:
fake_signatures.py 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
981c008269574d9bb73a2e781270e2163297b3d3ca9645b5e0664ffcbb19e78a,3cc2a888bae4811e75e64e19f2ce668951a3520e93e31a74b4cd4e9ce9508839,ed97aea4f9b66aca0c41ac88c2f0d90ef2ad269af0951ba2b07c70f7d1542b3c
53b9632a4250eb518426a545daa99fc6a72addfcb62714fbe81e269cd9ee39e8,62cbe3cc5eec2cbcbf61793a1d94414b43536c0e9219da703be5f141c46fa364,166db19e268d41b8cb76eedb50c57969635bcce2218b1921df45656a24de751a
a050e9237241c02d17684df9b9039fd707fcecb2fbd9d46af95dfeb6ef1daaa3,5e3bd1a08a7418066e4231adbfa23cc969617bb67f35a5f9a4d1ebae9a196fc7,a20a81207eb5aa382759debfc3ca98d4a3cf85474c9dbb6684dbd5bae3abe58d
9f2e42881a9cd3ddd088ebc77857beb9929c42e76e3b3ab7d1928652d2b731cf,0a4353b1fe7c167d63eaa45aeb23f83d219fd31ca74a17adc84cb18bc3184833,32a9cacbb64e5679eb40dfca1192bccc3db0e19d63d1e68286fe119d7d494c8a
a46f5889983efb70e00927f5afeeb2c4042783ca36525968657e339416a6bd8d,185c697570158909298fb10019d7a3e62ed647e9a6ecd1992f3d3098a498eec9,dcd110dd05f2ef9bb46639b0abe858a545bc61f1cd0e5462f41e7003d5f68bba
8ca48464e4dd3789ec41b83827b93e840471cfce2c8e6349e4087f56c335991f,6fb96292e9a2e5480085d9b8f69bd6aa62cee3b76b090cd5d5e25f8ce253adea,b6b20ab75d2ad6e8e79fe3fdc9e28a66e2a6acecfe87a7f33cb5c3fba1d070d3
Those signatures are only fake, because there is no known transaction that can be hashed to any of this z-value. That's the only reason, but from lattice point of view, they are as good as any real signatures, there is no difference in this attack, because knowing relations between nonces or some bits of private keys or nonces is more important than having a real signature.

So, if you want to break for example puzzle 120, you don't need two real weak signatures. You need two any weak signatures, that are valid from ECDSA point of view, and that will pass lattice attack (because you cannot use for example N and N-1, they are too close and if one signature will be a tweaked version of another one, it will obviously not work). You don't need any real transaction that can be hashed to z-value, because after breaking the private key, you could make it and sign it from scratch.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 23, 2022, 05:43:53 AM

I try to learn and understand math
Did I understand correctly?
this script method use leak nonce that generates to recover private key right?
script it not use way collect data from all data from signature with?
this lattice-attack use only one signature with leak 8-bit leak nonce to calculate correctly?
just loop search from 1000 signature until found one can calculate


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 23, 2022, 06:14:28 AM
Quote
this script method use leak nonce that generates to recover private key right?
Yes.

Quote
script it not use way collect data from all data from signature with?
You only need a public key and r,s,z values. They don't have to be collected from real transactions, they only have to be correct from ECDSA point of view.

Quote
this lattice-attack use only one signature with leak 8-bit leak nonce to calculate correctly?
The number of bits is configurable, you can set it to any value you want. And based on that number of leaked bits, you need more or less signatures to run this code.

Quote
just loop search from 1000 signature until found one can calculate
No, this code doesn't work for 1000 signatures. It is focused on a small number of signatures. If you provide more of them, then some of them will be picked randomly. If you have a lot of known bits, then one signature is enough. If you have less, then maybe two, maybe three. There is a function in this code that can tell you how many signatures you need, it depends on how many bits are known. But the maximum is somewhere around 100 as far as I can tell, using more signatures will cause it to pick some of them and work on a smaller number of signatures.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 23, 2022, 09:10:52 AM

this script it is the same of lattice-attack or not
https://asecuritysite.com/signatures/ecd
I see it is using LLL and reduction same
from sample how can expand the matrix to very large enough can search number
sorry I do not yet understand clear in math of lattice algorithms


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 23, 2022, 10:03:19 AM
Quote
this script it is the same of lattice-attack or not
Yes, it is. You can even use the same signatures and import them to your python script to see, that it will also find the same private key.

Quote
I see it is using LLL and reduction same
Yes, because LLL is the first step in your python script.

Quote
from sample how can expand the matrix to very large enough can search number
You can find the source article for the page you mentioned in your post: https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

Quote
sorry I do not yet understand clear in math of lattice algorithms
Keep reading, take your time. ECDSA, lattice attacks, hash functions, all of those things belong to advanced maths, so it is normal that it takes some time to learn.


Title: Re: lattice-attack || how to run without error
Post by: litecoin_messiah on April 23, 2022, 06:18:01 PM
 https://youtu.be/RgbrpmJ49r4 (https://youtu.be/RgbrpmJ49r4)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 24, 2022, 03:18:51 AM

I try to learn and understand math
Did I understand correctly?
this script method use leak nonce that generates to recover private key right?
script it not use way collect data from all data from signature with?
this lattice-attack use only one signature with leak 8-bit leak nonce to calculate correctly?
just loop search from 1000 signature until found one can calculate


You have a scrypt with "loop" ? I can provide file rsz sighnatures from any bitcoin afress with outgoin trsnsactions....


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on April 24, 2022, 08:23:44 AM
@garlonicon
above example is leak known bit atlast 4 bit need, with min 90 sign else attack will not work.
so each r,s with 0 to 15 (4 bit) need to be test.
each result with 90 sign look like lot of processing power need for this.

if possible to design Matrix to test each 4 bit with each pair of r,s then may be this attack is possible.
but i don't think this possible. is it ?


Title: Re: lattice-attack || how to run without error
Post by: ymgve2 on April 24, 2022, 06:07:46 PM
Quote
Realy ? Generate someonevfakecrsz please forvwalid bupkey, and for ex valid s...
No problem. There are fake r,s,z values for the public key from the Genesis Block:
Quote
Code:
fake_signatures.py 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
981c008269574d9bb73a2e781270e2163297b3d3ca9645b5e0664ffcbb19e78a,3cc2a888bae4811e75e64e19f2ce668951a3520e93e31a74b4cd4e9ce9508839,ed97aea4f9b66aca0c41ac88c2f0d90ef2ad269af0951ba2b07c70f7d1542b3c
53b9632a4250eb518426a545daa99fc6a72addfcb62714fbe81e269cd9ee39e8,62cbe3cc5eec2cbcbf61793a1d94414b43536c0e9219da703be5f141c46fa364,166db19e268d41b8cb76eedb50c57969635bcce2218b1921df45656a24de751a
a050e9237241c02d17684df9b9039fd707fcecb2fbd9d46af95dfeb6ef1daaa3,5e3bd1a08a7418066e4231adbfa23cc969617bb67f35a5f9a4d1ebae9a196fc7,a20a81207eb5aa382759debfc3ca98d4a3cf85474c9dbb6684dbd5bae3abe58d
9f2e42881a9cd3ddd088ebc77857beb9929c42e76e3b3ab7d1928652d2b731cf,0a4353b1fe7c167d63eaa45aeb23f83d219fd31ca74a17adc84cb18bc3184833,32a9cacbb64e5679eb40dfca1192bccc3db0e19d63d1e68286fe119d7d494c8a
a46f5889983efb70e00927f5afeeb2c4042783ca36525968657e339416a6bd8d,185c697570158909298fb10019d7a3e62ed647e9a6ecd1992f3d3098a498eec9,dcd110dd05f2ef9bb46639b0abe858a545bc61f1cd0e5462f41e7003d5f68bba
8ca48464e4dd3789ec41b83827b93e840471cfce2c8e6349e4087f56c335991f,6fb96292e9a2e5480085d9b8f69bd6aa62cee3b76b090cd5d5e25f8ce253adea,b6b20ab75d2ad6e8e79fe3fdc9e28a66e2a6acecfe87a7f33cb5c3fba1d070d3
Those signatures are only fake, because there is no known transaction that can be hashed to any of this z-value. That's the only reason, but from lattice point of view, they are as good as any real signatures, there is no difference in this attack, because knowing relations between nonces or some bits of private keys or nonces is more important than having a real signature.

So, if you want to break for example puzzle 120, you don't need two real weak signatures. You need two any weak signatures, that are valid from ECDSA point of view, and that will pass lattice attack (because you cannot use for example N and N-1, they are too close and if one signature will be a tweaked version of another one, it will obviously not work). You don't need any real transaction that can be hashed to z-value, because after breaking the private key, you could make it and sign it from scratch.

How did you generate those fake signatures, though? I'm assuming you did some manipulation of an existing signature, which means the new signatures will have a linear relationship with the original and each other, making them useless for lattice attacks. Are they even weak, or does the process generate a completely random unknown nonce?


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 25, 2022, 03:11:51 AM
I try to test with private key 120-bit script can fine 120-bit key (just modify the script random number from curve 256bit to random 120 bit)

if like to test with puzzle 120 how to implement to hash (z)

in the sample, file generate data.json have only R and S  and 8bit leak nonce
What is the data message at the end file on data.json

it is just for testing (possible not works)


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on April 25, 2022, 12:20:30 PM
@ymgve2
To generate fake r,s,z you can use public point and calculate 2 random and add it.
For example G is ecdsa SECP256k1 generator, PublicKey is ecdsa point, N is order

u = randint(1, N)
v = randint(1, N)
r = (u*G+v*PublicKey).x.num % N;
s = r * pow(v, N-2, N) % N
z = u * s % N

Now you have valid r,s,z pair for that public key.

@fxsniper
lattice attacks script leak 6 bit when use gen_data.py but you can use 4 bit too its minimum and 100 r,s,z,leak data need else this attack will not work.
Still there is no way to leak or know 4 bit even for generated or original signed R.


Title: Re: lattice-attack || how to run without error
Post by: ymgve2 on April 25, 2022, 02:49:36 PM
@ymgve2
To generate fake r,s,z you can use public point and calculate 2 random and add it.
For example G is ecdsa SECP256k1 generator, PublicKey is ecdsa point, N is order

u = randint(1, N)
v = randint(1, N)
r = (u*G+v*PublicKey).x.num % N;
s = r * pow(v, N-2, N) % N
z = u * s % N

Now you have valid r,s,z pair for that public key.

@fxsniper
lattice attacks script leak 6 bit when use gen_data.py but you can use 4 bit too its minimum and 100 r,s,z,leak data need else this attack will not work.
Still there is no way to leak or know 4 bit even for generated or original signed R.


With that method, you don't know anything about the nonce, since it would be k = u + v*priv and you don't know the private key. So it will not be weak, and useless for lattice attacks.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 25, 2022, 03:57:50 PM
Quote
With that method, you don't know anything about the nonce, since it would be k = u + v*priv and you don't know the private key. So it will not be weak, and useless for lattice attacks.
You are almost right. Almost, because you can try using non-random values and see, what would happen then, and why it can be useful for some attacks.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 26, 2022, 12:33:58 AM
@ymgve2
To generate fake r,s,z you can use public point and calculate 2 random and add it.
For example G is ecdsa SECP256k1 generator, PublicKey is ecdsa point, N is order

u = randint(1, N)
v = randint(1, N)
r = (u*G+v*PublicKey).x.num % N;
s = r * pow(v, N-2, N) % N
z = u * s % N

Now you have valid r,s,z pair for that public key.

@fxsniper
lattice attacks script leak 6 bit when use gen_data.py but you can use 4 bit too its minimum and 100 r,s,z,leak data need else this attack will not work.
Still there is no way to leak or know 4 bit even for generated or original signed R.


 I thinnk posible try with  MSB OR LSB 0000 OR 0000 0000

Z IS a sighned message, i thin it is in data(i dont remember exact)


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on April 26, 2022, 01:11:49 PM

@fxsniper
lattice attacks script leak 6 bit when use gen_data.py but you can use 4 bit too its minimum and 100 r,s,z, leak data need else this attack will not work.
Still, there is no way to leak or know 4 bit even for generated or original signed R.


Thank you I try 4 bit already, I use by command
python gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 4 -t MSB -n 50
python gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 4 -t LSB -n 50

I found some key lattice-attack can not be found the key. lattice-attack can not be found 100%

I think lattice-attack is not worked for solve puzzle

We are just users of lattice, just users use it
if lattice-attack it works I think many mathematics use it for

however, if using lattice-attack should be doing like use Kangaroo solve ECDSA need developer code and apply it a new one

I believe all methods on the internet that publish still can not use for solve puzzle #120
A better method is used generate a key to sample and create new one algorithm that can find key



Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 26, 2022, 01:36:41 PM

@fxsniper
lattice attacks script leak 6 bit when use gen_data.py but you can use 4 bit too its minimum and 100 r,s,z, leak data need else this attack will not work.
Still, there is no way to leak or know 4 bit even for generated or original signed R.


Thank you I try 4 bit already, I use by command
python gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 4 -t MSB -n 50
python gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 4 -t LSB -n 50

I found some key lattice-attack can not be found the key. lattice-attack can not be found 100%

I think lattice-attack is not worked for solve puzzle

We are just users of lattice, just users use it
if lattice-attack it works I think many mathematics use it for

however, if using lattice-attack should be doing like use Kangaroo solve ECDSA need developer code and apply it a new one

I believe all methods on the internet that publish still can not use for solve puzzle #120
A better method is used generate a key to sample and create new one algorithm that can find key



I develop my own method based on dividing pubkey, but for found root divifer (dividing without float part) needs pubkeys in amount of down range, for ex if down to 40 bit, need 2^40 pubkeys !!

Lattice work, but lattice not most good method, also for ex https://github.com/malb/bdd-predicate


Title: Re: lattice-attack || how to run without error
Post by: CrunchyF on April 28, 2022, 09:14:35 AM


Hi garlonicon.

Please can u explain this part of your code?

Code:
z/r=SHA-256("120-bit puzzle")=c43bc2e003908850dda3ff2fec69c3028027260ea7eef98746260eb83abe0a18
s/r=SHA-256("garlonicon")=272fc6644fedff1a897d6034bed23f61859e99440ee699033307976590316723

I understand that you calculate a new signature from R = pubkey.x
but i don't why you use pseudo random value for z/r and s/r


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on April 28, 2022, 03:48:04 PM
Quote
but i don't why you use pseudo random value for z/r and s/r
Because then it can be similar to some real signature in a real transaction. Hash functions are perfect for getting pseudorandom values that has some nice properties. I could use small values like 1,2,3, I could invent values like 1234567890, but hashing something gives you some pseudorandom value, so it is easier to just call some hash function and make it deterministic, than to invent your own way of getting random values. Also, there are just examples, so I don't need truly random numbers and I can just make it pseudorandom. Another reason is that if you want to test things, you can hash small numbers, like SHA-256("1"), and reproduce that easily, without storing all hashes.


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on April 28, 2022, 04:51:11 PM
@garlonicon
Is there any reason why attack fail one of random value is liner ?
For example i used
u =randint(1, N);
v = randint(1, N);
then loop it
u = u +1 keep v same to get LSB of nonce only increasing.
but lattice attack fail with "infinite loop in babai"

Unless both value is random its not working and no way to leak nonce on that case. any idea ?


Title: Re: lattice-attack || how to run without error
Post by: vjudeu on April 28, 2022, 07:51:31 PM
Quote
but lattice attack fail with "infinite loop in babai"
There are errors in this code, so if it cannot find the private key by using LLL reduction, it will go to other algorithms and will fail. Or there are missing assertions, so some arguments are passed into some algorithms, and you reach things like dividing by zero, in some internal implementation of some other algorithms. That usually happens when you have one tweaked signature instead of having two different signatures.

Quote
Unless both value is random its not working and no way to leak nonce on that case. any idea ?
The randomness is the thing that can feed LLL to produce the key. If you have only one signature (you can always do that, just by starting from one fake random signature), you cannot just tweak that single signature and expect it to behave in the same way as two different signatures. They are still connected, because you only slightly tweaked it, so it looks like trying to solve x=2y equation by adding 2x=4y equation. It will not help you. Also, x+1=2y+1 will not help you either. You need something like x=y+1, then you will know that x=2 and y=1.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on April 28, 2022, 09:23:35 PM
Quote
but lattice attack fail with "infinite loop in babai"
There are errors in this code, so if it cannot find the private key by using LLL reduction, it will go to other algorithms and will fail. Or there are missing assertions, so some arguments are passed into some algorithms, and you reach things like dividing by zero, in some internal implementation of some other algorithms. That usually happens when you have one tweaked signature instead of having two different signatures.

Quote
Unless both value is random its not working and no way to leak nonce on that case. any idea ?
The randomness is the thing that can feed LLL to produce the key. If you have only one signature (you can always do that, just by starting from one fake random signature), you cannot just tweak that single signature and expect it to behave in the same way as two different signatures. They are still connected, because you only slightly tweaked it, so it looks like trying to solve x=2y equation by adding 2x=4y equation. It will not help you. Also, x+1=2y+1 will not help you either. You need something like x=y+1, then you will know that x=2 and y=1.

Bast choice use a sighnatures from 1 transaction but with multiply ouputs. All sighnatures will be with same lenght and z value, bat i not shure all same z sighs is good or bad.



Quote
but lattice attack fail with "infinite loop in babai"
There are errors in this code, so if it cannot find the private key by using LLL reduction, it will go to other algorithms and will fail. Or there are missing assertions, so some arguments are passed into some algorithms, and you reach things like dividing by zero, in some internal implementation of some other algorithms. That usually happens when you have one tweaked signature instead of having two different signatures.

Quote
Unless both value is random its not working and no way to leak nonce on that case. any idea ?
The randomness is the thing that can feed LLL to produce the key. If you have only one signature (you can always do that, just by starting from one fake random signature), you cannot just tweak that single signature and expect it to behave in the same way as two different signatures. They are still connected, because you only slightly tweaked it, so it looks like trying to solve x=2y equation by adding 2x=4y equation. It will not help you. Also, x+1=2y+1 will not help you either. You need something like x=y+1, then you will know that x=2 and y=1.

Bast choice use a sighnatures from 1 transaction but with multiply ouputs. All sighnatures will be with same lenght and z value, bat i not shure all same z sighs is good or bad.

And order p+1,p-1 maybe help too



This is another interistig, I think. All this codes find a PRIVATE KEYS OF EC PUBLICK KEYS !!!:

https://crypto.stackexchange.com/questions/25644/elliptic-curve-brute-forcing

https://crypto.stackexchange.com/questions/6061/discrete-logs-on-elliptic-curve-with-embedding-degree-3-with-the-mov-attack/6071#6071

https://pastebin.com/jGB9sTq8

Need try this codes for secp256k1

This sage code contain all examples hot to modify previous codes for secp256k1

https://github.com/christianlundkvist/blog/blob/master/2020_05_26_secp256k1_twist_attacks/secp256k1_twist_attacks.md

Try someone modify codes, what result you get ?

Please not talk what this codes not work befo try. In any book no info, what if divide 120 publick  key to 2^40, you get 2^80 pubkey, and posible to additionaly downgrade 2^40 pubkeys to 2^20 pubkeys. And Zielar, for ex, can hack easy 2^80 pubkey, with 2^20 pubkeys, because hi has money and we are not have. Share any of your result to others in this thread, this knowlage is realy hard, chanses what someone will be more faster then you and get any publick key privkey is very small, but if we are share knolage maybe we get result, and not only blablabla...


Regards





Enother method for finding privkey from professor of cryptography

https://replit.com/@billbuchanan/gomov


Try please modify this code and share results, I cant do all work along !

Br.



Patented scalar multyplication 30% faster then doublevand add

https://ethresear.ch/t/introducing-bandersnatch-a-fast-elliptic-curve-built-over-the-bls12-381-scalar-field/9957



Lattice attack ex, i not try. Try someone ?

Use trick in nonce...  ::)

https://github.com/mimoo/SSL-TLS-ECDSA-timing-attack/blob/master/setup/client/offline/lattice.sage

[moderator's note: consecutive posts merged]


Title: Re: lattice-attack || how to run without error
Post by: bigvito19 on May 16, 2022, 11:05:41 AM
I was attempting to use this but did get a lot if errors.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 16, 2022, 11:17:55 AM
I was attempting to use this but did get a lot if errors.

Linck with code and descryption for recovering private key from sighnatures. Code in python for work with 128 bit nonce only:

code: https://asecuritysite.com/ecc/ecd

desryption:

https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

hoe to modify code for work with 256 bit sighnatures ?


Title: Re: lattice-attack || how to run without error
Post by: bigvito19 on May 16, 2022, 11:46:57 AM
I was attempting to use this but did get a lot if errors.

Linck with code and descryption for recovering private key from sighnatures. Code in python for work with 128 bit nonce only:

code: https://asecuritysite.com/ecc/ecd

desryption:

https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

how to modify code for work with 256 bit sighnatures ?


I already told you to just change lines 17 and 18 to 256 and it will work https://asecuritysite.com/ecc/ecd

k1 = random.randrange(1, pow(2, 256))
k2 = random.randrange(1, pow(2, 256))


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 16, 2022, 12:36:08 PM
I was attempting to use this but did get a lot if errors.

Linck with code and descryption for recovering private key from sighnatures. Code in python for work with 128 bit nonce only:

code: https://asecuritysite.com/ecc/ecd

desryption:

https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

how to modify code for work with 256 bit sighnatures ?


I already told you to just change lines 17 and 18 to 256 and it will work https://asecuritysite.com/ecc/ecd

k1 = random.randrange(1, pow(2, 256))
k2 = random.randrange(1, pow(2, 256))

private key ot found.

only message"private kwy", but no second message "privatevkey found"


Title: Re: lattice-attack || how to run without error
Post by: bigvito19 on May 16, 2022, 01:12:47 PM
I was attempting to use this but did get a lot if errors.

Linck with code and descryption for recovering private key from sighnatures. Code in python for work with 128 bit nonce only:

code: https://asecuritysite.com/ecc/ecd

desryption:

https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

how to modify code for work with 256 bit sighnatures ?


I already told you to just change lines 17 and 18 to 256 and it will work https://asecuritysite.com/ecc/ecd

k1 = random.randrange(1, pow(2, 256))
k2 = random.randrange(1, pow(2, 256))

private key ot found.

only message"private kwy", but no second message "privatevkey found"

What private key it was looking for because it was random


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 16, 2022, 01:26:25 PM
I was attempting to use this but did get a lot if errors.

Linck with code and descryption for recovering private key from sighnatures. Code in python for work with 128 bit nonce only:

code: https://asecuritysite.com/ecc/ecd

desryption:

https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

how to modify code for work with 256 bit sighnatures ?


I already told you to just change lines 17 and 18 to 256 and it will work https://asecuritysite.com/ecc/ecd

k1 = random.randrange(1, pow(2, 256))
k2 = random.randrange(1, pow(2, 256))

private key ot found.

only message"private kwy", but no second message "privatevkey found"

What private key it was looking for because it was random

yes random, you can replace generetated r,s from rundom to r,s from vitcoiin sighnature, after it will be not rundom.

but, rhis wersion for 128 bit nonce. btx is a 252-256 bit nonce


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on May 17, 2022, 12:58:07 PM
@COBRAS
Its different attack with lowest nonce under 127 bit & his weakness.

Only bitlogik lattice-attack is most powerful i can feel.

For example if you have any private key under 128 bit. for example puzzle 120.
If you use liner random value or single known higher random(0xf000000000000000000000000000000000000000000000000000000000000000) to start with and divide it in each time till 100 sign is made.(after 51 sign can use 128 bit random to make sign.)
You just have 33 or less nonce kp to worry about, because rest is 0 on MSB
i tested on my single pc with 16 thread its not powerful to cover it.
need atlast 128 thread with 4/5 pc to finish whole range fast.


Title: Re: lattice-attack || how to run without error
Post by: bigvito19 on May 17, 2022, 01:55:21 PM
I got the bitlogik lattice-attack to work    https://github.com/bitlogik/lattice-attack

So how do I go about attacking an public key or public keys?


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 17, 2022, 02:44:29 PM
@COBRAS
Its different attack with lowest nonce under 127 bit & his weakness.

Only bitlogik lattice-attack is most powerful i can feel.

For example if you have any private key under 128 bit. for example puzzle 120.
If you use liner random value or single known higher random(0xf000000000000000000000000000000000000000000000000000000000000000) to start with and divide it in each time till 100 sign is made.(after 51 sign can use 128 bit random to make sign.)
You just have 33 or less nonce kp to worry about, because rest is 0 on MSB
i tested on my single pc with 16 thread its not powerful to cover it.
need atlast 128 thread with 4/5 pc to finish whole range fast.

So, you need 128 or 4*128 thread ?

64 thread is possible, I think 128 possible too.

Your code work with less 128 but nonce, you tested it ?

P.s. then I try with 0000 msb and lsb, nothing found with his lattice attack.

R.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 18, 2022, 09:07:39 PM
Quote
Only bitlogik lattice-attack is most powerful i can feel.
I tried it, but it is somewhat buggy. You can take 120-bit key and use two random 120-bit values to get as many 240-bit signatures as you need (because first you will add one random 120-bit number to another 120-bit number, and then you will multiply that by another 120-bit value, by choosing the right range, you can always make sure that the first 16 bits are zero). No matter how many 240-bit k-values in signatures I had, I could never reach any 120-bit key from that. LLL is going through that without printing any key, and then another algorithms have some bugs, because there are "infinite loop in babai" and other similar messages in their internal implementation.

So, I partially know how to attack 120-bit keys, but I cannot do that in practice (because this code is buggy, it would take some time to fix it).


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on May 19, 2022, 08:53:44 AM
@garlonicon
i don't think its bug.
"infinite loop in babai"
I think it's like math divide by 0 on lattice attack.
First calculated sign must be higher int value like i have posted.
0xf000000000000000000000000000000000000000000000000000000000000000
Later sign can use divide by 14 or 10 etc, til int reach to 2 then can use random 128 bit int and all this is valid and give first 33 only non zero MSB rest all are 0 starting K on MSB.
i have tested with all possible combination no matter what i try i can't go lower then 33 kp requirement for 4 bit leaking.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 19, 2022, 04:39:22 PM
Quote
i don't think its bug
It is a bug, because the code should not inform you that "something went wrong", but should give you the exact reason of what was wrong, and also why it could be wrong. Scripts should not just crash if you feed them with invalid entries. They should tell you, what is the correct format and why something does not work. So, "infinite loop in babai" says nothing. It says that there is some loop and that loop is infinite. But there could be a lot of reasons, actually, an assertion saying that "value==something" was false in file "sample.py" on line 123 would be a lot better than that. Also, I think that signatures are random enough, they are just random 240-bit values that are not connected at all. Adding random 120-bit and multiplying the result by random 120-bit will shuffle and mix everything, no matter what was the key we started with. And we can get infinitely many signatures, so there always will be enough to try this kind of attack (also because there was an example with only six known bits that was solved correctly).


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 20, 2022, 02:03:49 AM
Quote
i don't think its bug
It is a bug, because the code should not inform you that "something went wrong", but should give you the exact reason of what was wrong, and also why it could be wrong. Scripts should not just crash if you feed them with invalid entries. They should tell you, what is the correct format and why something does not work. So, "infinite loop in babai" says nothing. It says that there is some loop and that loop is infinite. But there could be a lot of reasons, actually, an assertion saying that "value==something" was false in file "sample.py" on line 123 would be a lot better than that. Also, I think that signatures are random enough, they are just random 240-bit values that are not connected at all. Adding random 120-bit and multiplying the result by random 120-bit will shuffle and mix everything, no matter what was the key we started with. And we can get infinitely many signatures, so there always will be enough to try this kind of attack (also because there was an example with only six known bits that was solved correctly).

Hello, did you try this code ? Maybe this code had no bag, and more "powerful" for this talk, because has 3;algorithm include lattice  

https://github.com/malb/bdd-predicate


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 20, 2022, 03:04:49 AM
@garlonicon

You know how to downgrade pubkey range ? I try, but with div or substraction but this like how to shut to the the galaxy from the gun. Task is finding very small range, for ex 2^80, need search this 2^80 in 2^119 so, about 549755813888 publick of 2^80  in range 2^119+2^119(total 1/2 of 2^150.

Substraction had same difficulty's. Then substract, after you get pubkey smaller then target pubkey, difficulties of pubkey start grow, against fail...

???


It is possible make fake rsz for known pubkey ?

Can someone generate rsz for pubkey 120 for ex , in format of lattice-attack script or  bkz-preducate ?

Br


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 20, 2022, 04:25:36 AM
Quote
i don't think its bug
It is a bug, because the code should not inform you that "something went wrong", but should give you the exact reason of what was wrong, and also why it could be wrong. Scripts should not just crash if you feed them with invalid entries. They should tell you, what is the correct format and why something does not work. So, "infinite loop in babai" says nothing. It says that there is some loop and that loop is infinite. But there could be a lot of reasons, actually, an assertion saying that "value==something" was false in file "sample.py" on line 123 would be a lot better than that. Also, I think that signatures are random enough, they are just random 240-bit values that are not connected at all. Adding random 120-bit and multiplying the result by random 120-bit will shuffle and mix everything, no matter what was the key we started with. And we can get infinitely many signatures, so there always will be enough to try this kind of attack (also because there was an example with only six known bits that was solved correctly).

I have a communication with bitlogic (lattice-attack code)r previously. If you can explain what a bag I cab ask him for remove bag, or you can send him message directly.


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 20, 2022, 06:59:27 PM
@garlonicon
 

It is possible make fake rsz for known pubkey ?

Can someone generate rsz for pubkey 120 for ex , in format of lattice-attack script or  bkz-preducate ?

Br


yes Cobras

we can make valid transactions for pubkey, only then when this pubkey has minimum one output

i need : pubkey (x,y) , and transaction output as r s z

then I make perform "gauss reduction for this pubkey", result will be:
pubkey (still the same)
new r,s,z valid for this pubkey (valid means : ecdsa verify)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 20, 2022, 08:19:51 PM
@garlonicon
 

It is possible make fake rsz for known pubkey ?

Can someone generate rsz for pubkey 120 for ex , in format of lattice-attack script or  bkz-preducate ?

Br


yes Cobras

we can make valid transactions for pubkey, only then when this pubkey has minimum one output

i need : pubkey (x,y) , and transaction output as r s z

then I make perform "gauss reduction for this pubkey", result will be:
pubkey (still the same)
new r,s,z valid for this pubkey (valid means : ecdsa verify)

I will make for 120, and simple with many transaction.

Little later today or tomorrow. Don go far away  from this thread


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 20, 2022, 08:27:12 PM
no problem.


now I writing my own attack:

example :

I have pubkey with one output r,s,z

so I know r,s,z

we all know that if r  (which is nonce*G) -> so if nonce is less 125 bit -> lattice standard reduction will find privatekey when we have only one output (one transaction)

so : We can make perform "new" transaction as below with loop:

 new r_new,s_new,h_new for the same pubkey as old_nonce minus 2**i bit
then test in lattice that r (as nonce*G is in 0 to 125 bit):)
if not -> then minus 2**i bit and so on:)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 20, 2022, 08:36:43 PM
no problem.


now I writing my own attack:

example :

I have pubkey with one output r,s,z

so I know r,s,z

we all know that if r  (which is nonce*G) -> so if nonce is less 125 bit -> lattice standard reduction will find privatekey when we have only one output (one transaction)

so : We can make perform "new" transaction as below with loop:

 new r_new,s_new,h_new for the same pubkey as old_nonce minus 2**i bit
then test in lattice that r (as nonce*G is in 0 to 125 bit):)
if not -> then minus 2**i bit and so on:)


You really can make code for this , and code for gauss reduction ?

P.s. I will provide rsz  for you any way


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 20, 2022, 08:40:22 PM
yes,



Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 20, 2022, 09:05:37 PM
Quote
i need : pubkey (x,y) , and transaction output as r s z
You need only pubkey. For lattice attack, your r,s,z can be faked, it will be as useful as something collected from some real transaction.

Quote
new r_new,s_new,h_new for the same pubkey as old_nonce minus 2**i bit
Quote
The randomness is the thing that can feed LLL to produce the key. If you have only one signature (you can always do that, just by starting from one fake random signature), you cannot just tweak that single signature and expect it to behave in the same way as two different signatures. They are still connected, because you only slightly tweaked it, so it looks like trying to solve x=2y equation by adding 2x=4y equation. It will not help you. Also, x+1=2y+1 will not help you either. You need something like x=y+1, then you will know that x=2 and y=1.
And that's why it would be better to start with 120-bit key, and make a lot of 240-bit signatures. You need some randomness to make it. I think getting it squared should be random enough to reveal the key, but this code still does not work for me, this "infinite loop in babai" is annoying and simply means that LLL found nothing, so other algorithms were used (and they failed somehow).


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 21, 2022, 06:22:14 AM
why randomnes?

example :

private key = 2**254
nonce = 2**200

and I have one r,s,z as r = nonce *G

I dont know k but know r,s,z and pubkey

then:
1. make new transaction for this pubkey as  k - 2**10 > it is nonce 2*190 -> new s , new z -> check in lattice -> not find k
2. make new transaction for this pubkey as  k - 2**20 > it is nonce 2*180 -> new s , new z -> check in lattice -> not find k
.....
20. new transaction for this pubkey as  k - 2**80 > it is nonce 2*120 -> new s , new z -> check in lattice -> : founded k:)
then calculate private key:)

Bro, I cant find a my crypt  fir getting  all rsz from 1 adress, but for one rsz this utill is good:

https://github.com/iceland2k14/rsz

waiting from you generated rsz data with nonce <=128 bit

ps

code for calculating how many bits in r:


file = open('r.txt', 'r+')
for address in file.readlines():

    num = int(address)
    length = len(bin(num))
    length -=2
    print ("total number of bits: ", length)


Title: Re: lattice-attack || how to run without error
Post by: brainless on May 21, 2022, 09:01:32 AM
i don;t understand

I can make valid new transactions from valid transaction but need pubkey and r,s,z from this transaction

if you give me pubkey and r,s,z then I will give you sample :) few transactions as valid
original RSZ from 120

     R: 00a285a9151ac1f9c40e88a2a80b79c702336536462a9390fd00dda999da45420a
     S: 1844883eb808df18a9138ee2c13439ecf716799edcf073772f2696e4f9384f58
     Z: 7e17cf7c5b7ccfaa4c7c05874e4fb4f12661662b8e33188e2e62b3739931ade5
PubKey: 02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 21, 2022, 12:18:57 PM
Code:
#puzzle 120 bit
#pubkey: 02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
#orignal r 73510839094214084184271166420450064382033414643777332160226424786083490644490
#orignal s 10976594294804291513495419880246258022106887857042165878188703008731415727960
#orignal z 57033488418143403036276105049800667624117951758937049013745927841702009220581
#transaction no 1
r1= 64303877522016749211328019369486855559381583676185624818721878054372774312312
s1= 70875935156883017289107359601022834131678723222382391732673864919336300956832
z1= 35661757295778441922079074467255901080139542633440413895572608785090077596810
#ecdsa verify with pubkey : signature matches
#transaction no 2
r2= 113779420052094348549790625183876838964910120506875492617325148867041134611828
s2= 96745938684674252071471302417800048447980988178881028616577919694871256968444
z2= 98246022210272637262013100016624594634461243839177892990658396738754206074658
#ecdsa verify with pubkey : signature matches
#transaction no 3
r3= 73747527950084943081014066025721979101835505522277265880132019814117348403688
s3= 60853612463764314593593189942506162309685078640419983461023904463111781219874
z3= 67681371259005467470285887789884648655153421391057790433988472875579507892348
#ecdsa verify with pubkey : signature matches
#transaction no 4
r4= 75314523162015442440660600468028764137673617222885550022074746107917840302622
s4= 14569616503728591410238910269631849279226193629982420163055031991462228437199
z4= 78075666291674269562723582424350797980288665770729771649502233772300923016682
#ecdsa verify with pubkey : signature matches

you need only one of this  transaction - outgoing transaction


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on May 21, 2022, 01:40:31 PM
@COBRAS
hello
This is puzzle 120 public calculated 100 sample with 120 bit random data
MSB 16 bits is must "0000" in nonce, tested with multiple 120 bit range my own sample private keys.

https://pastebin.com/RTg4PVv0
For LLL.reduction its no issue but BKZ.reduction will show error "infinite loop in babai"
Same in liner random.

This can't be fixed so far i know.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 21, 2022, 05:03:28 PM
@ecdsa123

You get all data what you need for make lattice ?



cobras:


here you have new transactions generate for pubkey

it has been designed from the original from blockchain.

check below:

Code:
#puzzle 120 bit
#pubkey: 02ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
#orignal r 73510839094214084184271166420450064382033414643777332160226424786083490644490
#orignal s 10976594294804291513495419880246258022106887857042165878188703008731415727960
#orignal z 57033488418143403036276105049800667624117951758937049013745927841702009220581
#transaction no 1
r1= 64303877522016749211328019369486855559381583676185624818721878054372774312312
s1= 70875935156883017289107359601022834131678723222382391732673864919336300956832
z1= 35661757295778441922079074467255901080139542633440413895572608785090077596810
#ecdsa verify with pubkey : signature matches
#transaction no 2
r2= 113779420052094348549790625183876838964910120506875492617325148867041134611828
s2= 96745938684674252071471302417800048447980988178881028616577919694871256968444
z2= 98246022210272637262013100016624594634461243839177892990658396738754206074658
#ecdsa verify with pubkey : signature matches
#transaction no 3
r3= 73747527950084943081014066025721979101835505522277265880132019814117348403688
s3= 60853612463764314593593189942506162309685078640419983461023904463111781219874
z3= 67681371259005467470285887789884648655153421391057790433988472875579507892348
#ecdsa verify with pubkey : signature matches
#transaction no 4
r4= 75314523162015442440660600468028764137673617222885550022074746107917840302622
s4= 14569616503728591410238910269631849279226193629982420163055031991462228437199
z4= 78075666291674269562723582424350797980288665770729771649502233772300923016682
#ecdsa verify with pubkey : signature matches

how many none bit in sighs ?

for latticce i think alll sighs mast be same bits. But yours trans N2 is not  equeilto others transaction by lenght - r2 is bigger then r at other sighs



it is the same bits as original r

it is designed :
original transaction : nonce k->unknown   

first transaction: nonce + 10 | or nonce + 100 (sorry don;t remember)
second transaction: nonce + 20 | or nonce + 200 (sorry don;t remember)

third transaction: nonce + 30 | or nonce + 300 (sorry don;t remember)

fourth transaction: nonce + 40 | or nonce + 400 (sorry don;t remember)

where nonce is still the same from original



transaction has msb or lsb ?

you make gauss reduction for them ?

on this adress only  1 transaction for output transaction, doing something with input transaction and add them to lattice matrix  bad idia....

then you will modify  sighs from 256 bit to 100 ?




in this example : all 4 transactions have the same msb -   more than 240 bit



can you generate for puz 120,  89 sighns with nonce not more 2^248 ?

you can do it without msb or lsb





no one can, unless you know the privkey


but you can make reductions, it take times, and you have to write algorithm to this.
it is simple -> math and 128 cores, or GPU and coder which can implement algorithm in c++

at the moment i'm almost finish math equation for this.

yoy can find 128 core at https://vast.ai/

[moderator's note: consecutive posts merged]


Title: Re: lattice-attack || how to run without error
Post by: bigvito19 on May 21, 2022, 11:10:03 PM
This is an example from the data.json file from https://github.com/bitlogik/lattice-attack


{"curve": "SECP256K1", "public_key": [66412380102939781024918160349386680014552536369061587637080774389860461092925, 43765600116551195273677149966008783624760986110490190619082891899095205821463], "known_type": "LSB", "known_bits": 6, "signatures": [{"r": 77527664235581399957092079345479688400475999610428178825522649055070157244692, "s": 27028479468528243957334746793835087615740874028178347534667218420099431266524, "kp": 51, "hash": 36925504434266069211917383521197840104244330385311344434522880060028429358956}, {"r": 1695214956238129249280118258814363243967244974939577175204794511553033886344, "s": 84915535421556974430475608108845062567200591001138706902138971666887762297461, "kp": 23, "hash": 76485972818364982894032873079629726025969313708578174583231327504986349400949}, {"r": 109269381046386034156037076068908319933850763940108273610325408412215759654951, "s": 48609197671516297208867726715248596584655415925682996149314879813291177259719, "kp": 49, "hash": 8857850795789766547675189849758610890848461200122419912004299328172940180927}, {"r": 41835540276419198058500360048414380626372941221767888918686846392248041576696, "s": 1825469084617584873286736453038639812754935222429578990673573348028125348352, "kp": 29, "hash": 11771613120662486178657899205469606751879506909643902145426207541353014498651}, {"r": 107103142771724135475440435595118756234545765813796109423691918131480012001322, "s": 76403726951992633295737606623610572293691262686449016257400538234410247449075, "kp": 44, "hash": 109029154205057617106956764551702586575882058359417649302233515615948131520073}, {"r": 54544573696288124190943111180088654937224138523771919858599448193516058012815, "s": 75774534848938869077595821409914703967303095416625781047518021857023231109081, "kp": 44, "hash":


Is this the public key its trying to look for [66412380102939781024918160349386680014552536369061587637080774389860461092925, 43765600116551195273677149966008783624760986110490190619082891899095205821463] ?

So I convert the r,s,z into decimal, I see the r and s. Which one is the z, is it the kp?

I'm trying to see what goes where.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 21, 2022, 11:46:54 PM
This is an example from the data.json file from https://github.com/bitlogik/lattice-attack


{"curve": "SECP256K1", "public_key": [66412380102939781024918160349386680014552536369061587637080774389860461092925, 43765600116551195273677149966008783624760986110490190619082891899095205821463], "known_type": "LSB", "known_bits": 6, "signatures": [{"r": 77527664235581399957092079345479688400475999610428178825522649055070157244692, "s": 27028479468528243957334746793835087615740874028178347534667218420099431266524, "kp": 51, "hash": 36925504434266069211917383521197840104244330385311344434522880060028429358956}, {"r": 1695214956238129249280118258814363243967244974939577175204794511553033886344, "s": 84915535421556974430475608108845062567200591001138706902138971666887762297461, "kp": 23, "hash": 76485972818364982894032873079629726025969313708578174583231327504986349400949}, {"r": 109269381046386034156037076068908319933850763940108273610325408412215759654951, "s": 48609197671516297208867726715248596584655415925682996149314879813291177259719, "kp": 49, "hash": 8857850795789766547675189849758610890848461200122419912004299328172940180927}, {"r": 41835540276419198058500360048414380626372941221767888918686846392248041576696, "s": 1825469084617584873286736453038639812754935222429578990673573348028125348352, "kp": 29, "hash": 11771613120662486178657899205469606751879506909643902145426207541353014498651}, {"r": 107103142771724135475440435595118756234545765813796109423691918131480012001322, "s": 76403726951992633295737606623610572293691262686449016257400538234410247449075, "kp": 44, "hash": 109029154205057617106956764551702586575882058359417649302233515615948131520073}, {"r": 54544573696288124190943111180088654937224138523771919858599448193516058012815, "s": 75774534848938869077595821409914703967303095416625781047518021857023231109081, "kp": 44, "hash":


Is this the public key its trying to look for [66412380102939781024918160349386680014552536369061587637080774389860461092925, 43765600116551195273677149966008783624760986110490190619082891899095205821463] ?

So I convert the r,s,z into decimal, I see the r and s. Which one is the z, is it the kp?

I'm trying to see what goes where.

Read careful example file and will find all you need. first kp for ex =  51.hash is a z


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 22, 2022, 06:53:07 AM
Quote
can you generate for puz 120,  89 sighns with nonce not more 2^248 ?
Quote
no one can, unless you know the privkey
It is the opposite, everyone can do that. As I said, you only need the public key: https://pastebin.com/4fxUSrZT
Code:
x=0xceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a2630
y=0x2b195386bea3f5f002dc033b92cfc2c9e71b586302b09cfe535e1ff290b1b5ac

r1=c923e141c9c6d8aacc1cda5f5fb88f04deb0b9edc4dcfb7fdedbfa5e378f7be4
s1=d94dda4835f0f508ce3dd254e1dbb305036ff2d730d358d88a3baabe9d62b8dd
z1=20a4ddb78e28c3a53c205044e406033888d0747104a1aa7cea6060f745f01b3c

n=fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

1/r1=53491f1b04c43dd53f7fb49494addad940a027ffdd1a8c1042b8d8b2533057ac
1/s1=be72598b2890fb2dc5e9516660a3938c2227e0d4c48b3acf8265c2e224204572

z1*(1/r1)=00000000000000000000000000000000000c7076345d228cafad703a4c7d02d8
r1*(1/s1)=000000000000000000000000000000000048a18eb8762a75cfc41e17ae48e0c5
As you can see, it works. There are 100 signatures. Lattice cannot reveal the solution, no matter that all signatures are in 240-bit range. By checking "z/r" and "r/s", you can make sure that all of my signatures are in the correct range, just assume that the private key is in 120-bit range, and do addition/multiplication to see the range of the signature nonces.


Title: Re: lattice-attack || how to run without error
Post by: stanner.austin on May 22, 2022, 08:43:55 AM
@garlonicon
Confuse with nonce and random int use in signing ?
Even with nonce 1 random int in sign always in 250 or higher bit.

From public key we can multiply random int which increase public key hidden number known as K,
so random int is a * K = R is generated.

Code:
private key 0x1000
public points
px: 0x175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739
py: 0xd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695

k:1
r: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
s: 0xe667ef9dcbbac55a06295ce870b079d3efe3a465c532ef334320987bf4d736a5
z: 0x0

SIGN_U: 0x0000000000000000000000000000000000000000000000000000000000000000
SIGN_V: 0x13efffffffffffffffffffffffffffffe6a9fe543746b7faa740723d177739b5

as you can see example
0x13efffffffffffffffffffffffffffffe6a9fe543746b7faa740723d177739b5

Now same public key with 120 bit random int for multiplication

Code:
K: 0x000000000000000000000000000000079d523ff7bb533dc6d6fabf75a30ac000
R: 0xdaff9f3f66aae00146a41c5401fa148a9f3945b9bb9045f12c21d0bf43b5b330
S: 0x45127dc4fbeffc546746250887e2aadcbd214576b74b0202a2667ae3ad900a59
Z: 0x0000000000000000000000000000000000000000000000000000000000000000
SIGN_U: 0x0000000000000000000000000000000000000000000000000000000000000000
SIGN_V: 0x000000000000000000000000000000000079d523ff7bb533dc6d6fabf75a30ac
Sign is := True

as you see, K is multiply whatever value we use for random int.

How ever there is one more thing if we multiply any public key with (N//2)+1 strange K come if private key is EVEN.
This break private key in half. K is half of private key so R is half of public key.

Example
Code:
K: 0x0000000000000000000000000000000000000000000000000000000000000800
R: 0x5d1bdb4ea172fa79fce4cc2983d8f8d9fc318b85f423de0dedcb63069b920471
S: 0xba37b69d42e5f4f3f9c9985307b1f1b3f863170be847bc1bdb96c60d372408e2
Z: 0x0000000000000000000000000000000000000000000000000000000000000000
SIGN_U: 0x0000000000000000000000000000000000000000000000000000000000000000
SIGN_V: 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1
Sign is := True


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 22, 2022, 02:37:29 PM
First, we look at signatures:
Code:
s=(z+rd)/k
sk=z+rd
sk-z=rd
(sk-z)/r=d
(s/r)k-(z/r)=d
(z/r)+d=(s/r)k
k=((z/r)+d)*(r/s)
Then, things are quite simple:
Code:
z/r=random
r/s=random
But we can do more than that:
Code:
z/r=120_bit_number_v1
r/s=120_bit_number_v2
k=(120_bit_number_v1+d)*120_bit_number_v2
If "d" is our 120_bit_privkey, then first we add another 120_bit number to that (we can use 119-bit numbers to be 100% sure). Then, we have 121-bit number at most, it cannot be bigger. And if we multiply that by another 119-bit number (just to be sure), then we will have 121+119=240 bits in our result. It cannot be bigger than that, because if you multiply M-bit number by N-bit number, then the result has at most M+N bits. So, in this way I can be absolutely sure that if "d" is a 120-bit number, then "k" is a 240-bit number. In the same way, it is possible to generate many signatures with many different N-bit values. But it is still not enough to use that in a lattice attack, because it needs some randomness in the right places, so something else is also needed to make it.

Edit:
Quote
show your code
Code:
def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16) #119-bit to be 100% sure to not fall into 241-bit range
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120)
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 22, 2022, 07:21:40 PM

@garlonicon, @ecdsa123 please reascthis pdf file. This is intresting fresh methos with success >60% but need deper knowlage of math and python then what I have.


https://eprint.iacr.org › ...PDF
A Tale of Three Signatures: practical attack of ECDSA with wNAF

You will find this pdf easy in google.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 22, 2022, 07:25:08 PM
Quote
becouse now it is generator , you have connected transactions
They are not, because it is used for hashing. So, you have SHA-256 of that. You can put "random" numbers here, but hashing can make it easier to reproduce each result when needed.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 22, 2022, 07:27:51 PM
First, we look at signatures:
Code:
s=(z+rd)/k
sk=z+rd
sk-z=rd
(sk-z)/r=d
(s/r)k-(z/r)=d
(z/r)+d=(s/r)k
k=((z/r)+d)*(r/s)
Then, things are quite simple:
Code:
z/r=random
r/s=random
But we can do more than that:
Code:
z/r=120_bit_number_v1
r/s=120_bit_number_v2
k=(120_bit_number_v1+d)*120_bit_number_v2
If "d" is our 120_bit_privkey, then first we add another 120_bit number to that (we can use 119-bit numbers to be 100% sure). Then, we have 121-bit number at most, it cannot be bigger. And if we multiply that by another 119-bit number (just to be sure), then we will have 121+119=240 bits in our result. It cannot be bigger than that, because if you multiply M-bit number by N-bit number, then the result has at most M+N bits. So, in this way I can be absolutely sure that if "d" is a 120-bit number, then "k" is a 240-bit number. In the same way, it is possible to generate many signatures with many different N-bit values. But it is still not enough to use that in a lattice attack, because it needs some randomness in the right places, so something else is also needed to make it.

Edit:
Quote
show your code
Code:
def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16) #119-bit to be 100% sure to not fall into 241-bit range
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120)
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret

can we add to sighnatures  121 bit what starts with 000000 ? this will.make lsb from our sighs ?

if we thant divede is more easy, I try this method on publick key. For removing trandfer from + area to - area, is more good start with pubkey * -1, this will transfer pubkey priv range from -1 to -1-rage, result will belarge than -1, and range will be simple without start from 1 to N,, -N to -F, and will be -N to -F...



this is puzzle 100 privkey

./md 0xaf55fc59c335c8ec67ed24826 - 0xfffffffffffffffffffffffff
Result: fffffffffffffffffffffffffffffffebaaedce1a4a865d7f32eed534f088968

then subsract too mach, tlrange will be shifted to negative area, and nothin will be found in positivevsearch range

but then start from negative area result will be maybe negative too

./md 0xfffffffffffffffffffffffffffffffebaaedcdbb9e8da9f8c75cfc65163f91b + 0xffffffffffffffffffffffff
Result: fffffffffffffffffffffffffffffffebaaedcdcb9e8da9f8c75cfc65163f91a

so search in negative area is more good I think.

but found how many need substeact is not solved me. then subsract too mach privkey if publey start accumulate more bits, not substract.

ps maybe this info will be helpfull





Code:
[code]I have rewrite code for sagemath


from hashlib import sha256

 
import struct

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
a = 0
b = 7
G = (0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

E = EllipticCurve(GF(p), [a, b])
G = E(G)


def bytes_to_long(s):
    """bytes_to_long(strinng) : long
    Convert a byte string to a long integer.
    This is (essentially) the inverse of long_to_bytes().
    """
    acc = 0L
    unpack = struct.unpack
    length = len(s)
    if length % 4:
        extra = (4 - length % 4)
        s = b('\000') * extra + s
        length = length + extra
    for i in range(0, length, 4):
        acc = (acc << 32) + unpack('>I', s[i:i+4])[0]
    return acc
def H(m):
h = sha256()
h.update(m)
return bytes_to_long(h.digest())
def egcd(a, b):
    "Euclidean greatest common divisor"
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    "Modular inverse"
    # in Python 3.8 you can simply return pow(a,-1,m)
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m 
def verify(pub,r, s, m):
    v1 = m*modinv(s, n) % n
    v2 = r*modinv(s, n) % n
    V = v1*G + v2*pub
    x,y=V.xy()
    return int(x) % n == r,hex(int(v1)),hex(int(v2))
def calc_k(num,r,s,z):
    k=(r*num + z)*modinv(s,n)%n
    return k,n-k   
sign=[]
ge=[]

def calc_x(a,b,r,s,z):
    #x1 = (z1 -b)*modinv(a*s1-r1,n)%n
     
    x_a =(z -b)%n
    x_b=(a*s-r)%n
    if x_b != 0:
        return (x_a*modinv(x_b,n)%n)%n
    return 0
def generates_signatures():
    puzzle120=16
     
    n_value=n
    sigs = []
    private=50
    Qp=private*G
    for index in range(130):
        print("---- index",index)
        binaryIndex=int((index*3)).to_bytes(32,'big')
        binaryIndex2=int((index*2+1)).to_bytes(32,'big')
        hashedIndex=H(binaryIndex)
        hashedIndex2=H(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point= int(z_value_with_r)*G
        final_point=Qp+added_point
        r_value_with_s=(hashedIndex2%puzzle120)
        print(r_value_with_s)
        if r_value_with_s!=0:
            R_point=final_point*int(r_value_with_s)
            x,y=R_point.xy()
            r_value=int(x)
            s_value_with_r=int(modinv(r_value_with_s,n)%n)
            s_value=int((s_value_with_r*r_value)%n)
            z_value=((z_value_with_r*r_value)%n)
            print("r", r_value)
            print("s", s_value)
            print("hash", z_value)
            k,k1=calc_k(private,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            print(verify(Qp,r_value,s_value,z_value))
            wy,b,a=verify(Qp,r_value,s_value,z_value)
            x=calc_x(int(a,16),int(b,16),int(r_value),int(s_value),int(z_value))
            print("x",x)
            k,k1=calc_k(x,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            t=tuple([r_value,s_value,z_value])
            if t not in sign:
                sign.append(t)
                for le in range(0,1000):
                    k2=(k*2**le)%n
                    ge.append(int(k2))
                    ge.append(int(n-k2))
generates_signatures()






here is part of output:

Code:
---- index 18
9
r 63933145574282734898435981717146773918756897333098319278256437952015461322467
s 97164196692832900318159208530884680987624427476291405550721397771404732420314
hash 0
k 450 115792089237316195423570985008687907852837564279074904382605163141518161493887
k 0x1c2 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f
(True, '0x0', '0x9')
x 0


so according above:

private key = 50
k= 450

how the nonce k is calculated from pubkey (private key)
simple:
a*d + b = k nonce
here a=9 and b = 0
so 9* 50 + 0 = 450
confirm : (True, '0x0', '0x9')

it is generator

it is useless.

[/code]


./md 450 x -1
Result: fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f

= 115792089237316195423570985008687907852837564279074904382605163141518161493887

this is inversion of 450

you thant say what this is real nonce ?


I think generator  must be for ex y = X^400, x is a generator. .

Br




Cobras:

./md 450 x -1
Result: fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f

= 115792089237316195423570985008687907852837564279074904382605163141518161493887

this is inversion of 450

this value 115792089237316195423570985008687907852837564279074904382605163141518161493887 = n-450

so d*(-1)%n = n-d
:)


but according Garlonicon Generator ( yes, it is master math deduction Bravo for Garlonicon), we can use it:
becouse:

Code:
---- index 18
37929
r 106052440004676334409650332163651951923042923173423795888106072423870533309482
s 86487388237072824922585675463188678676341543446573502861944943782026730667995
hash 110763458801388154151046907647238024857062280457110140174709389756661623888001
k 1495388754 115792089237316195423570985008687907852837564279074904382605163141516666105583
k 0x5921d252 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8c77146eef
(True, '0x5904e250', '0x9429')
x 0
k 1493492304 115792089237316195423570985008687907852837564279074904382605163141516668002033
k 0x5904e250 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8c77315ef1
---- index 19
21317
r 18103990796095223393229492283858137777181144560247153354193996653271708547693
s 71995424062587838315307175718789388226264777318544777869325093881612562000023
hash 74553635558632807494232092124236529938587320104480240499961671012084809061673
k 139541082 115792089237316195423570985008687907852837564279074904382605163141518021953255
k 0x8513a5a 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cc7e506e7
(True, '0x840f6e0', '0x5345')
x 0
k 138475232 115792089237316195423570985008687907852837564279074904382605163141518023019105
k 0x840f6e0 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cc7f54a61

we know a part of k for any transaction(index)

see Index 19:
real k in transaction : k 139541082
but we know to real part as bits from this k : k 138475232

we can try use Lcd algorithm.

Tomorrow I will try check.


 :) ok, waiting result with big interest

ps
139541082
13 is 2 bytes, so 16 bits, this is enoth for finding priv...

for all other transaction we have 2 bytes 2 )

try please find 2 bytes it will be good too .... :) I know what you know this, but maybe you forget avout it.. :)


regards



Code:
[code]I have rewrite code for sagemath


from hashlib import sha256

 
import struct

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
a = 0
b = 7
G = (0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

E = EllipticCurve(GF(p), [a, b])
G = E(G)


def bytes_to_long(s):
    """bytes_to_long(strinng) : long
    Convert a byte string to a long integer.
    This is (essentially) the inverse of long_to_bytes().
    """
    acc = 0L
    unpack = struct.unpack
    length = len(s)
    if length % 4:
        extra = (4 - length % 4)
        s = b('\000') * extra + s
        length = length + extra
    for i in range(0, length, 4):
        acc = (acc << 32) + unpack('>I', s[i:i+4])[0]
    return acc
def H(m):
h = sha256()
h.update(m)
return bytes_to_long(h.digest())
def egcd(a, b):
    "Euclidean greatest common divisor"
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    "Modular inverse"
    # in Python 3.8 you can simply return pow(a,-1,m)
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m 
def verify(pub,r, s, m):
    v1 = m*modinv(s, n) % n
    v2 = r*modinv(s, n) % n
    V = v1*G + v2*pub
    x,y=V.xy()
    return int(x) % n == r,hex(int(v1)),hex(int(v2))
def calc_k(num,r,s,z):
    k=(r*num + z)*modinv(s,n)%n
    return k,n-k   
sign=[]
ge=[]

def calc_x(a,b,r,s,z):
    #x1 = (z1 -b)*modinv(a*s1-r1,n)%n
     
    x_a =(z -b)%n
    x_b=(a*s-r)%n
    if x_b != 0:
        return (x_a*modinv(x_b,n)%n)%n
    return 0
def generates_signatures():
    puzzle120=16
     
    n_value=n
    sigs = []
    private=50
    Qp=private*G
    for index in range(130):
        print("---- index",index)
        binaryIndex=int((index*3)).to_bytes(32,'big')
        binaryIndex2=int((index*2+1)).to_bytes(32,'big')
        hashedIndex=H(binaryIndex)
        hashedIndex2=H(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point= int(z_value_with_r)*G
        final_point=Qp+added_point
        r_value_with_s=(hashedIndex2%puzzle120)
        print(r_value_with_s)
        if r_value_with_s!=0:
            R_point=final_point*int(r_value_with_s)
            x,y=R_point.xy()
            r_value=int(x)
            s_value_with_r=int(modinv(r_value_with_s,n)%n)
            s_value=int((s_value_with_r*r_value)%n)
            z_value=((z_value_with_r*r_value)%n)
            print("r", r_value)
            print("s", s_value)
            print("hash", z_value)
            k,k1=calc_k(private,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            print(verify(Qp,r_value,s_value,z_value))
            wy,b,a=verify(Qp,r_value,s_value,z_value)
            x=calc_x(int(a,16),int(b,16),int(r_value),int(s_value),int(z_value))
            print("x",x)
            k,k1=calc_k(x,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            t=tuple([r_value,s_value,z_value])
            if t not in sign:
                sign.append(t)
                for le in range(0,1000):
                    k2=(k*2**le)%n
                    ge.append(int(k2))
                    ge.append(int(n-k2))
generates_signatures()






here is part of output:

Code:
---- index 18
9
r 63933145574282734898435981717146773918756897333098319278256437952015461322467
s 97164196692832900318159208530884680987624427476291405550721397771404732420314
hash 0
k 450 115792089237316195423570985008687907852837564279074904382605163141518161493887
k 0x1c2 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f
(True, '0x0', '0x9')
x 0


so according above:

private key = 50
k= 450

how the nonce k is calculated from pubkey (private key)
simple:
a*d + b = k nonce
here a=9 and b = 0
so 9* 50 + 0 = 450
confirm : (True, '0x0', '0x9')

it is generator

it is useless.

[/code]


./md 450 x -1
Result: fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f

= 115792089237316195423570985008687907852837564279074904382605163141518161493887

this is inversion of 450

you thant say what this is real nonce ?


I think generator  must be for ex y = X^400, x is a generator. .

Br

Someone, please, upload sage scryot to transfer.sh I from phone, very hard copy/paste without lost tabulation

Regards



@ecdsa123 is any news about lcd ?

br



Code:
[code]I have rewrite code for sagemath


from hashlib import sha256

 
import struct

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
a = 0
b = 7
G = (0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

E = EllipticCurve(GF(p), [a, b])
G = E(G)


def bytes_to_long(s):
    """bytes_to_long(strinng) : long
    Convert a byte string to a long integer.
    This is (essentially) the inverse of long_to_bytes().
    """
    acc = 0L
    unpack = struct.unpack
    length = len(s)
    if length % 4:
        extra = (4 - length % 4)
        s = b('\000') * extra + s
        length = length + extra
    for i in range(0, length, 4):
        acc = (acc << 32) + unpack('>I', s[i:i+4])[0]
    return acc
def H(m):
h = sha256()
h.update(m)
return bytes_to_long(h.digest())
def egcd(a, b):
    "Euclidean greatest common divisor"
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    "Modular inverse"
    # in Python 3.8 you can simply return pow(a,-1,m)
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m 
def verify(pub,r, s, m):
    v1 = m*modinv(s, n) % n
    v2 = r*modinv(s, n) % n
    V = v1*G + v2*pub
    x,y=V.xy()
    return int(x) % n == r,hex(int(v1)),hex(int(v2))
def calc_k(num,r,s,z):
    k=(r*num + z)*modinv(s,n)%n
    return k,n-k   
sign=[]
ge=[]

def calc_x(a,b,r,s,z):
    #x1 = (z1 -b)*modinv(a*s1-r1,n)%n
     
    x_a =(z -b)%n
    x_b=(a*s-r)%n
    if x_b != 0:
        return (x_a*modinv(x_b,n)%n)%n
    return 0
def generates_signatures():
    puzzle120=16
     
    n_value=n
    sigs = []
    private=50
    Qp=private*G
    for index in range(130):
        print("---- index",index)
        binaryIndex=int((index*3)).to_bytes(32,'big')
        binaryIndex2=int((index*2+1)).to_bytes(32,'big')
        hashedIndex=H(binaryIndex)
        hashedIndex2=H(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point= int(z_value_with_r)*G
        final_point=Qp+added_point
        r_value_with_s=(hashedIndex2%puzzle120)
        print(r_value_with_s)
        if r_value_with_s!=0:
            R_point=final_point*int(r_value_with_s)
            x,y=R_point.xy()
            r_value=int(x)
            s_value_with_r=int(modinv(r_value_with_s,n)%n)
            s_value=int((s_value_with_r*r_value)%n)
            z_value=((z_value_with_r*r_value)%n)
            print("r", r_value)
            print("s", s_value)
            print("hash", z_value)
            k,k1=calc_k(private,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            print(verify(Qp,r_value,s_value,z_value))
            wy,b,a=verify(Qp,r_value,s_value,z_value)
            x=calc_x(int(a,16),int(b,16),int(r_value),int(s_value),int(z_value))
            print("x",x)
            k,k1=calc_k(x,r_value,s_value,z_value)
             
            print("k",k,k1)
            print("k",hex(k),hex(k1))
            t=tuple([r_value,s_value,z_value])
            if t not in sign:
                sign.append(t)
                for le in range(0,1000):
                    k2=(k*2**le)%n
                    ge.append(int(k2))
                    ge.append(int(n-k2))
generates_signatures()






here is part of output:

Code:
---- index 18
9
r 63933145574282734898435981717146773918756897333098319278256437952015461322467
s 97164196692832900318159208530884680987624427476291405550721397771404732420314
hash 0
k 450 115792089237316195423570985008687907852837564279074904382605163141518161493887
k 0x1c2 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0363f7f
(True, '0x0', '0x9')
x 0


so according above:

private key = 50
k= 450

how the nonce k is calculated from pubkey (private key)
simple:
a*d + b = k nonce
here a=9 and b = 0
so 9* 50 + 0 = 450
confirm : (True, '0x0', '0x9')

it is generator

it is useless.

[/code]

formule "450 / 9 = priv" not work for all sighns.

I thin is very hard or inposivle crack with lattice . Method very expesive of time...

[moderator's note: consecutive posts merged]


Title: Re: lattice-attack || how to run without error
Post by: NotATether on May 24, 2022, 03:53:24 AM
formule "450 / 9 = priv" not work for all sighns.

I thin is very hard or inposivle crack with lattice . Method very expesive of time...

Have you ran benchmarks on this program? GNU/Linux has a "time" command which you can use to measure the running time of a program.

Maybe a little modular invert doesn't take much time but when you start doing that to hundreds of signatures, you start to notice the slwness.

Alternatively, you can gain a (limited) performance speedup by converting it to C language utilizing pthreads.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 24, 2022, 04:43:10 AM
formule "450 / 9 = priv" not work for all sighns.

I thin is very hard or inposivle crack with lattice . Method very expesive of time...

Have you ran benchmarks on this program? GNU/Linux has a "time" command which you can use to measure the running time of a program.

Maybe a little modular invert doesn't take much time but when you start doing that to hundreds of signatures, you start to notice the slwness.

Alternatively, you can gain a (limited) performance speedup by converting it to C language utilizing pthreads.


Lattice is about 500 sighnatures max. not cheched perfofance. but, formula 450 /9   work not for all sighnatures.

interesting check know part, I nit checked ... ni tine for this. If know part finder work ithis is a good new, and this enoth for find priv


ecdsa123, not answered, naybe hi provide something more interesting, will see

modular inv can make illusion of saccess, and add unknown var to formula. Then in fornula only uknown vars and them modification this maybe can be false positive results.Maybe ecdsa123, find false positive result and not writing more...

@ecdsa123, come on, lets talk, maybe we find something usefull  :)



Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 24, 2022, 06:56:33 AM
 


I thin is very hard or inposivle crack with lattice . Method very expesive of time...
 

 


ecdsa123, not answered, naybe hi provide something more interesting, will see

modular inv can make illusion of saccess, and add unknown var to formula. Then in fornula only uknown vars and them modification this maybe can be false positive results.Maybe ecdsa123, find false positive result and not writing more...

@ecdsa123, come on, lets talk, maybe we find something usefull  :)



first need speak with @Garlonicon


after a lot of tests...it could be works:) it is really hard but not impossible.
 


@Garlonicon, please write to me or change for allow to receive e-mail from newbie.
We really need to talk it is important for us both.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 24, 2022, 03:38:54 PM
Quote
or change for allow to receive e-mail from newbie
Changed. But I don't know, why I am so important? ECDSA security can be discussed publicly, for example here, in this topic. People should be aware of all possible attacks and be ready to deal with them. But of course I can also respond to private messages, no problem.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 24, 2022, 09:05:08 PM
Quote
or change for allow to receive e-mail from newbie
Changed. But I don't know, why I am so important? ECDSA security can be discussed publicly, for example here, in this topic. People should be aware of all possible attacks and be ready to deal with them. But of course I can also respond to private messages, no problem.

Yes, discus publicly. Sacces can be in 0,1%. Maybe someone can add good things to discus


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 24, 2022, 10:07:52 PM
Cobras,
it is almost impossible.


There could be chance , but implement enviroment for this , it is not for one person.

first -> please read WhiteBox find on google.


Title: Re: lattice-attack || how to run without error
Post by: iceland2k14 on May 25, 2022, 05:32:59 AM
As you can see, it works. There are 100 signatures. Lattice cannot reveal the solution, no matter that all signatures are in 240-bit range. By checking "z/r" and "r/s", you can make sure that all of my signatures are in the correct range, just assume that the private key is in 120-bit range, and do addition/multiplication to see the range of the signature nonces.

Signatures derived this way is most likely reaching to degenerate system of equations incomprehensible by Lattice reduction.


Title: Re: lattice-attack || how to run without error
Post by: CrunchyF on May 26, 2022, 02:50:58 PM
Signatures derived this way is most likely reaching to degenerate system of equations incomprehensible by Lattice reduction.

can u explain more please?


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 26, 2022, 04:18:35 PM
I think I understand. I guess it means that such attack is trying to solve x=2y by adding 2x=4y. It won't work. Why? Because it would be "degenerate system of equations", so it won't produce any new solutions, everything will be as unknown, as it was before.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 04:53:42 PM
I think I understand. I guess it means that such attack is trying to solve x=2y by adding 2x=4y. It won't work. Why? Because it would be "degenerate system of equations", so it won't produce any new solutions, everything will be as unknown, as it was before.

ecdsa123 realy find partial nonce ?


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on May 26, 2022, 05:37:06 PM
Quote
ecdsa123 realy find partial nonce ?
I don't know. For now, I don't have any proof. No moved coins, no revealed keys, so not yet. But I think it will soon be obvious, is this attack successful or not (today, I guess it will fail).


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 26, 2022, 07:31:30 PM
below output:
private key :101391487656071791739308955354353221

it is very hard (really hard), but not impossible.

analyse outputs

so: generate 2 x 8 transactions as:

1 to 8 and 1 to 8 as negative.

and r =  s :D

so : leak : 0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85
                
       leak : 0x000000000000013870c7de303201ef7a5128b8415b03821cfcdfe1085aed747a

joint together and perform ENHP + doubled reduction with pruned we can sii that output on 16 bits is our privatekey.

but -> this is for "theoretically" when you know exactly what range bit is you pubkey, without this knowledge , those attack is useless.

Code:
---- index 2
b1 828563692742190953435031129255502257
b2 1
private_key= 101391487656071791739308955354353221
r= 46229861362577657348883230286930550283029422510902563449097344654506052954192
s= 46229861362577657348883230286930550283029422510902563449097344654506052954192
z= 69127356212994433971961936139034293279280125764535349413784215476506050322431
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353225
k 0x1386fc7de303201ef7a5128b854e49
---- index 3
b1 1059764604409094661915420582155118655
b2 1
private_key= 101391487656071791739308955354353221
r= 81270736933848773201432693719467175556993668817347944273137496513945402306824
s= 81270736933848773201432693719467175556993668817347944273137496513945402306824
z= 36684096980741786271468333423077132895917633681682072162606489776399651795394
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353230
k 0x1386fc7de303201ef7a5128b854e4e

---- index 4
b1 1053090505275130897213577479594726285
b2 1
private_key= 101391487656071791739308955354353221
r= 57798083408359744185852689587076431915237529070280703337989574741548464413539
s= 57798083408359744185852689587076431915237529070280703337989574741548464413539
z= 114224709872542539008646138332407555673937515170966922729597053874148300156265
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353237
k 0x1386fc7de303201ef7a5128b854e55

---- index 5
b1 1182184834602935691675838270622206198
b2 1
private_key= 101391487656071791739308955354353221
r= 22896768549861177188618894925128618200521662573772617332095249803381859676283
s= 22896768549861177188618894925128618200521662573772617332095249803381859676283
z= 109250856797264648021188433093463823601691307228015815771960592518473845929727
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353246
k 0x1386fc7de303201ef7a5128b854e5e

---- index 6
b1 936436354164513705859390012411773597
b2 2
private_key= 101391487656071791739308955354353221
r= 98157279051420901681438534269018718490994115476390145375419795790206076769312
s= 98157279051420901681438534269018718490994115476390145375419795790206076769312
z= 59899368731666597824657683424036630090661228777798102036957754201873918865122
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353257
k 0x1386fc7de303201ef7a5128b854e69

---- index 7
b1 667766267559640815970592186816778420
b2 2
private_key= 101391487656071791739308955354353221
r= 34917474073994671512096634942880522257926070159206698205955523780576807918725
s= 34917474073994671512096634942880522257926070159206698205955523780576807918725
z= 89866980303312168162741322079514880698651537894079550735348381267009327096807
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353270
k 0x1386fc7de303201ef7a5128b854e76

---- index 8
b1 899222938459248123955393651504870457
b2 1
private_key= 101391487656071791739308955354353221
r= 1023773956584641394143043172774514169515022302837703076483767867177908846045
s= 1023773956584641394143043172774514169515022302837703076483767867177908846045
z= 65521533221417049225154763057568906848961427381612996894961143499386166146880
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353285
k 0x1386fc7de303201ef7a5128b854e85

---- index 9
b1 793545750785105509512695397468259361
b2 1
private_key= 101391487656071791739308955354353221
r= 63025268830972539032898882007349212363509258948290244197819228576990363602590
s= 63025268830972539032898882007349212363509258948290244197819228576990363602590
z= 10194848866863063027686102213018255919397146532213987188730336509420346058962
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353302
k 0x1386fc7de303201ef7a5128b854e96

---- index 2
b1 712164031399110853148060997745396865
b2 2
private_key= 101391487656071791739308955354353221
r= 27103883593015035580153318732623745998693028899207238705262187421936030077650
s= 85936906068667546152064093056257562813246504500278964233090557541971799625642
z= 55689630516085606767039379681723659457858755051541237726156369393804257765217
0x000000000000013870c7de303201ef7a5128b8415d03821cfcdfe1085aed747a 1961221116993664214726123333138751886130159056778677522887802
k 128530587123296777976291218760581243609426103945047410139975037375
k 0x13870c7de303201ef7a5128b8415d03821cfcdfe1085aed747ab1bf
---- index 3
b1 999519855688352828669916646653593406
b2 1
private_key= 101391487656071791739308955354353221
r= 30988929726604708011658681546827492104017932930830726500377383494517731514934
s= 108488270055588768902340451605889964585423314050499766752418467451860058982760
z= 111960438656388819175375468791871969257306903466782814182755700889761904876830
0x000000000000013870c7de303201ef7a5128b8415cb3821cfcdfe1085aed747a 1961221116993664214726123333138751789416093487608343546393722
k 128530587123296777976291218760581237271173102803900402656459010500
k 0x13870c7de303201ef7a5128b8415cb3821cfcdfe1085aed747ab1c4

---- index 4
b1 673421562781286763286090114264135927
b2 1
private_key= 101391487656071791739308955354353221
r= 100047160268814088122476934604887438392022379679644880795617565006873753922926
s= 29879057216974316665068715717559357836993849054281188315037370172536284875359
z= 10442177588343175125944149191407498545020888887340885698657463520800050054192
0x000000000000013870c7de303201ef7a5128b8415c43821cfcdfe1085aed747a 1961221116993664214726123333138751654016401690769875979302010
k 128530587123296777976291218760581228397618901206294592179536572875
k 0x13870c7de303201ef7a5128b8415c43821cfcdfe1085aed747ab1cb

---- index 5
b1 782204259740309676191665510552519855
b2 1
private_key= 101391487656071791739308955354353221
r= 67748688409753906884602585869273345848389578349559411830671900561331205619739
s= 47309353417989274342350451264526709897306334140787276564807909575268999346671
z= 9359688561069551322785662657644011076068777306365929214157633369647220268347
0x000000000000013870c7de303201ef7a5128b8415bb3821cfcdfe1085aed747a 1961221116993664214726123333138751479931083666263274821612666
k 128530587123296777976291218760581216988763499152229978709207724500
k 0x13870c7de303201ef7a5128b8415bb3821cfcdfe1085aed747ab1d4

---- index 6
b1 889675885620664284259029898527374932
b2 1
private_key= 101391487656071791739308955354353221
r= 91699128047693045096930506848575724991130596132336882202108285400796479070201
s= 70766148921323071743426706043410057226917081380666483725967635563455471584956
z= 25713929120436652797776881812114722851282252157891284853362375064908500464595
0x000000000000013870c7de303201ef7a5128b8415b03821cfcdfe1085aed747a 1961221116993664214726123333138751267160139414088540073325690
k 128530587123296777976291218760581203044606896641706562245472465375
k 0x13870c7de303201ef7a5128b8415b03821cfcdfe1085aed747ab1df

---- index 7
b1 910791372744195741880505594394083184
b2 2
private_key= 101391487656071791739308955354353221
r= 111282721658743511740804804218697831196755139209322001012141847896280895651065
s= 20579288142382667585932948745866031848399350165909282667115172199092943875501
z= 32503252789281607325637049393909307257007975756143400896227105022894316585376
0x000000000000013870c7de303201ef7a5128b8415a33821cfcdfe1085aed747a 1961221116993664214726123333138751015703568934245671734441082
k 128530587123296777976291218760581186565149093674724342788330795500
k 0x13870c7de303201ef7a5128b8415a33821cfcdfe1085aed747ab1ec

---- index 8
b1 960468925745871513192393263989646375
b2 1
private_key= 101391487656071791739308955354353221
r= 1515369974418220632208652282625175248945511303008693577523254516090366936025
s= 21694925889143481593597715975595471018570942820517802064685459752503618159085
z= 40255131991805909512837029349338246625087029878081478686158136638692234522003
0x000000000000013870c7de303201ef7a5128b8415943821cfcdfe1085aed747a 1961221116993664214726123333138750725561372226734669804958842
k 128530587123296777976291218760581167550390090251283320337782714875
k 0x13870c7de303201ef7a5128b8415943821cfcdfe1085aed747ab1fb

---- index 9
b1 1116188034818399715281488777861618067
b2 1
private_key= 101391487656071791739308955354353221
r= 67862418695230407003562437086472620407901995706496069748509522119750644330355
s= 53478305863170606567556942648286716062761137878253507961506721050769533525439
z= 88616475425151911347765754383696064726005866145971175258558068914159163941232
0x000000000000013870c7de303201ef7a5128b8415833821cfcdfe1085aed747a 1961221116993664214726123333138750396733549291555534284878970
k 128530587123296777976291218760581146000329886371383494893828223500
k 0x13870c7de303201ef7a5128b8415833821cfcdfe1085aed747ab20c

len 16
bit== 10
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 11
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 12
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 13
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 14
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 15
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 16
101391487656071791739308955354353221
115403
101391487656071791739308955354353221 101391487656071791739308955354353221 founded True 101391487656071791739308955354353221 -563222510236386144712594574785819067
bit== 17
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 18
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 19
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947


ps. time for finding if you know "subrange" almost 6 hours.
without knowing subrange - years years years

Ps. Cobras be sure better mathematician than me checked that, and they know that is useless.



Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 08:00:09 PM
below output:
private key :101391487656071791739308955354353221

it is very hard (really hard), but not impossible.

analyse outputs

so: generate 2 x 8 transactions as:

1 to 8 and 1 to 8 as negative.

and r =  s :D

so : leak : 0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85
                
       leak : 0x000000000000013870c7de303201ef7a5128b8415b03821cfcdfe1085aed747a

joint together and perform ENHP + doubled reduction with pruned we can sii that output on 16 bits is our privatekey.

but -> this is for "theoretically" when you know exactly what range bit is you pubkey, without this knowledge , those attack is useless.

Code:
---- index 2
b1 828563692742190953435031129255502257
b2 1
private_key= 101391487656071791739308955354353221
r= 46229861362577657348883230286930550283029422510902563449097344654506052954192
s= 46229861362577657348883230286930550283029422510902563449097344654506052954192
z= 69127356212994433971961936139034293279280125764535349413784215476506050322431
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353225
k 0x1386fc7de303201ef7a5128b854e49
---- index 3
b1 1059764604409094661915420582155118655
b2 1
private_key= 101391487656071791739308955354353221
r= 81270736933848773201432693719467175556993668817347944273137496513945402306824
s= 81270736933848773201432693719467175556993668817347944273137496513945402306824
z= 36684096980741786271468333423077132895917633681682072162606489776399651795394
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353230
k 0x1386fc7de303201ef7a5128b854e4e

---- index 4
b1 1053090505275130897213577479594726285
b2 1
private_key= 101391487656071791739308955354353221
r= 57798083408359744185852689587076431915237529070280703337989574741548464413539
s= 57798083408359744185852689587076431915237529070280703337989574741548464413539
z= 114224709872542539008646138332407555673937515170966922729597053874148300156265
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353237
k 0x1386fc7de303201ef7a5128b854e55

---- index 5
b1 1182184834602935691675838270622206198
b2 1
private_key= 101391487656071791739308955354353221
r= 22896768549861177188618894925128618200521662573772617332095249803381859676283
s= 22896768549861177188618894925128618200521662573772617332095249803381859676283
z= 109250856797264648021188433093463823601691307228015815771960592518473845929727
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353246
k 0x1386fc7de303201ef7a5128b854e5e

---- index 6
b1 936436354164513705859390012411773597
b2 2
private_key= 101391487656071791739308955354353221
r= 98157279051420901681438534269018718490994115476390145375419795790206076769312
s= 98157279051420901681438534269018718490994115476390145375419795790206076769312
z= 59899368731666597824657683424036630090661228777798102036957754201873918865122
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353257
k 0x1386fc7de303201ef7a5128b854e69

---- index 7
b1 667766267559640815970592186816778420
b2 2
private_key= 101391487656071791739308955354353221
r= 34917474073994671512096634942880522257926070159206698205955523780576807918725
s= 34917474073994671512096634942880522257926070159206698205955523780576807918725
z= 89866980303312168162741322079514880698651537894079550735348381267009327096807
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353270
k 0x1386fc7de303201ef7a5128b854e76

---- index 8
b1 899222938459248123955393651504870457
b2 1
private_key= 101391487656071791739308955354353221
r= 1023773956584641394143043172774514169515022302837703076483767867177908846045
s= 1023773956584641394143043172774514169515022302837703076483767867177908846045
z= 65521533221417049225154763057568906848961427381612996894961143499386166146880
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353285
k 0x1386fc7de303201ef7a5128b854e85

---- index 9
b1 793545750785105509512695397468259361
b2 1
private_key= 101391487656071791739308955354353221
r= 63025268830972539032898882007349212363509258948290244197819228576990363602590
s= 63025268830972539032898882007349212363509258948290244197819228576990363602590
z= 10194848866863063027686102213018255919397146532213987188730336509420346058962
0x000000000000000000000000000000000000001386fc7de303201ef7a5128b85 1547111322877072017506545339269
k 101391487656071791739308955354353302
k 0x1386fc7de303201ef7a5128b854e96

---- index 2
b1 712164031399110853148060997745396865
b2 2
private_key= 101391487656071791739308955354353221
r= 27103883593015035580153318732623745998693028899207238705262187421936030077650
s= 85936906068667546152064093056257562813246504500278964233090557541971799625642
z= 55689630516085606767039379681723659457858755051541237726156369393804257765217
0x000000000000013870c7de303201ef7a5128b8415d03821cfcdfe1085aed747a 1961221116993664214726123333138751886130159056778677522887802
k 128530587123296777976291218760581243609426103945047410139975037375
k 0x13870c7de303201ef7a5128b8415d03821cfcdfe1085aed747ab1bf
---- index 3
b1 999519855688352828669916646653593406
b2 1
private_key= 101391487656071791739308955354353221
r= 30988929726604708011658681546827492104017932930830726500377383494517731514934
s= 108488270055588768902340451605889964585423314050499766752418467451860058982760
z= 111960438656388819175375468791871969257306903466782814182755700889761904876830
0x000000000000013870c7de303201ef7a5128b8415cb3821cfcdfe1085aed747a 1961221116993664214726123333138751789416093487608343546393722
k 128530587123296777976291218760581237271173102803900402656459010500
k 0x13870c7de303201ef7a5128b8415cb3821cfcdfe1085aed747ab1c4

---- index 4
b1 673421562781286763286090114264135927
b2 1
private_key= 101391487656071791739308955354353221
r= 100047160268814088122476934604887438392022379679644880795617565006873753922926
s= 29879057216974316665068715717559357836993849054281188315037370172536284875359
z= 10442177588343175125944149191407498545020888887340885698657463520800050054192
0x000000000000013870c7de303201ef7a5128b8415c43821cfcdfe1085aed747a 1961221116993664214726123333138751654016401690769875979302010
k 128530587123296777976291218760581228397618901206294592179536572875
k 0x13870c7de303201ef7a5128b8415c43821cfcdfe1085aed747ab1cb

---- index 5
b1 782204259740309676191665510552519855
b2 1
private_key= 101391487656071791739308955354353221
r= 67748688409753906884602585869273345848389578349559411830671900561331205619739
s= 47309353417989274342350451264526709897306334140787276564807909575268999346671
z= 9359688561069551322785662657644011076068777306365929214157633369647220268347
0x000000000000013870c7de303201ef7a5128b8415bb3821cfcdfe1085aed747a 1961221116993664214726123333138751479931083666263274821612666
k 128530587123296777976291218760581216988763499152229978709207724500
k 0x13870c7de303201ef7a5128b8415bb3821cfcdfe1085aed747ab1d4

---- index 6
b1 889675885620664284259029898527374932
b2 1
private_key= 101391487656071791739308955354353221
r= 91699128047693045096930506848575724991130596132336882202108285400796479070201
s= 70766148921323071743426706043410057226917081380666483725967635563455471584956
z= 25713929120436652797776881812114722851282252157891284853362375064908500464595
0x000000000000013870c7de303201ef7a5128b8415b03821cfcdfe1085aed747a 1961221116993664214726123333138751267160139414088540073325690
k 128530587123296777976291218760581203044606896641706562245472465375
k 0x13870c7de303201ef7a5128b8415b03821cfcdfe1085aed747ab1df

---- index 7
b1 910791372744195741880505594394083184
b2 2
private_key= 101391487656071791739308955354353221
r= 111282721658743511740804804218697831196755139209322001012141847896280895651065
s= 20579288142382667585932948745866031848399350165909282667115172199092943875501
z= 32503252789281607325637049393909307257007975756143400896227105022894316585376
0x000000000000013870c7de303201ef7a5128b8415a33821cfcdfe1085aed747a 1961221116993664214726123333138751015703568934245671734441082
k 128530587123296777976291218760581186565149093674724342788330795500
k 0x13870c7de303201ef7a5128b8415a33821cfcdfe1085aed747ab1ec

---- index 8
b1 960468925745871513192393263989646375
b2 1
private_key= 101391487656071791739308955354353221
r= 1515369974418220632208652282625175248945511303008693577523254516090366936025
s= 21694925889143481593597715975595471018570942820517802064685459752503618159085
z= 40255131991805909512837029349338246625087029878081478686158136638692234522003
0x000000000000013870c7de303201ef7a5128b8415943821cfcdfe1085aed747a 1961221116993664214726123333138750725561372226734669804958842
k 128530587123296777976291218760581167550390090251283320337782714875
k 0x13870c7de303201ef7a5128b8415943821cfcdfe1085aed747ab1fb

---- index 9
b1 1116188034818399715281488777861618067
b2 1
private_key= 101391487656071791739308955354353221
r= 67862418695230407003562437086472620407901995706496069748509522119750644330355
s= 53478305863170606567556942648286716062761137878253507961506721050769533525439
z= 88616475425151911347765754383696064726005866145971175258558068914159163941232
0x000000000000013870c7de303201ef7a5128b8415833821cfcdfe1085aed747a 1961221116993664214726123333138750396733549291555534284878970
k 128530587123296777976291218760581146000329886371383494893828223500
k 0x13870c7de303201ef7a5128b8415833821cfcdfe1085aed747ab20c

len 16
bit== 10
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 11
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 12
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 13
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 14
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 15
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 16
101391487656071791739308955354353221
115403
101391487656071791739308955354353221 101391487656071791739308955354353221 founded True 101391487656071791739308955354353221 -563222510236386144712594574785819067
bit== 17
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 18
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947
bit== 19
-2575198776870092341
0
101391487656071791739308955354353221 -2575198776870092341 founded False 1329227995784915870328608283410252235 664613997892457933876704753270079947


ps. time for finding if you know "subrange" almost 6 hours.
without knowing subrange - years years years

Ps. Cobras be sure better mathematician than me checked that, and they know that is useless.



Hi.

k and k in your code is input ?

can you provide code and more description what is what ?

thx


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 26, 2022, 08:01:40 PM
no.
K is nonce in integer (for testing to know)

input are r,s,z generate by script from Garlonicon with my "modification".



Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 08:13:11 PM
@ecdsa, collect some real rsz from blockchain and try your code ?

can use 1 transaction with many output. Posibl it will be more easy for use

thx.


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 26, 2022, 08:39:18 PM
@ecdsa, collect some real rsz from blockchain and try your code ?

can use 1 transaction with many output. Posibl it will be more easy for use

thx.




it is useless. as inform if you know subrange it is 6 hours. if not "time is years ior milleniums",
I have use to try : https://eprint.iacr.org/2022/385     White-Box
 

and here pdf: https://eprint.iacr.org/2022/385.pdf


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 08:58:50 PM
@ecdsa, collect some real rsz from blockchain and try your code ?

can use 1 transaction with many output. Posibl it will be more easy for use

thx.







it is useless. as inform if you know subrange it is 6 hours. if not "time is years ior milleniums",
I have use to try : https://eprint.iacr.org/2022/385     White-Box
 

and here pdf: https://eprint.iacr.org/2022/385.pdf

how get subranges  ? code for get them pls ?


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 26, 2022, 09:13:40 PM
page no 18 in pdf

Code:
Finding the inversion of the nonce. During the computation of s, the nonce k
must be inverted modulo n. This operation is very sensitive and can be quite
difficult to protect. In Challenge 227, it is not performed in the clear: the value
of k is protected by the encoding function A(t) and by the matrix M . If we note
M =
(m0 m1
m2 m3
)
, the system that is solved for the computation of r and s is
{
m0(ks − e − dRx) + m1(r − Rx) = 0
m2(ks − e − dRx) + m3(r − Rx) = 0 . (21)
We stress that k, e and Rx do not appear in the clear. They are expressed as
linear combinations of the input u = A(t)(k, e, Rx, Ry ) of E(2).


so for us important is last sentence: 
They are expressed as linear combinations

so modificate garlonicon script for linear combination which you can easy calculate.
WHola. ende finish but is not for real " transactions", it is very very hard


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 09:16:02 PM
show priv of 120, 125 or 130 bit ouzzle ?

pls


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on May 26, 2022, 09:29:54 PM
. Cobras be sure better mathematician than me checked that, and they know that is useless.


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on May 26, 2022, 10:01:24 PM
. Cobras be sure better mathematician than me checked that, and they know that is useless.

 ::)

i not undertand this formulas, code too unfortunately.

Bro, provide any proof of work of your codes ? on github 1000+ attacks but they not work on real data.

generate sighs for this pub and find a key ?

04e36a3452c8921ea9e093ebb94f544cab434abadd796566280e05d5ae22fad6a2017cfa0647d6e 458b12848c03fac10e3c44ecf3911dc2f2da90afc1ccf36f9f9

?



@ecdsa123, help me in this thread pls ?

https://bitcointalk.org/index.php?topic=5400202.0

thanks


Title: Re: lattice-attack || how to run without error
Post by: ymgve2 on May 28, 2022, 10:38:58 PM
@ecdsa, collect some real rsz from blockchain and try your code ?

can use 1 transaction with many output. Posibl it will be more easy for use

thx.




it is useless. as inform if you know subrange it is 6 hours. if not "time is years ior milleniums",
I have use to try : https://eprint.iacr.org/2022/385     White-Box
 

and here pdf: https://eprint.iacr.org/2022/385.pdf

White box attacks, which those papers are about means the attacker is in full control of the computer that actually does the generation of the signature, and can measure timing and program flow during the generation of the signature. This is completely irrelevant to lattice attacks on weak nonces.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on June 05, 2022, 10:28:09 AM

What is this BKZ reduction : block size = 15
I test with 4-bit leak nonce and signature between 50-90 set
many key losses and some key can calculate with BKZ reduction : block size = 15 and next untile con recover (some)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on June 05, 2022, 03:14:03 PM

What is this BKZ reduction : block size = 15
I test with 4-bit leak nonce and signature between 50-90 set
many key losses and some key can calculate with BKZ reduction : block size = 15 and next untile con recover (some)


you try on real rsz from bitcoin blockchain ?


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on June 06, 2022, 01:27:07 AM

you try on real rsz from bitcoin blockchain ?

Maybe, Are you have any script for collecting thousands rsz?
but the problem is it is a 256-bit key not easy and it needs to develop high advance to do
maybe try a test with some brainwallets

but I would like to understand lattice first and how BKZ reduction: block size = 15 , it is works
can possibly use million block size or brute force it
I would like to try to modify the lattice-like use of kangaroo with collision
if not yet understand how it works, can not use it.



Title: Re: lattice-attack || how to run without error
Post by: COBRAS on June 06, 2022, 01:46:26 AM

you try on real rsz from bitcoin blockchain ?

Maybe, Are you have any script for collecting thousands rsz?
but the problem is it is a 256-bit key not easy and it needs to develop high advance to do
maybe try a test with some brainwallets

but I would like to understand lattice first and how BKZ reduction: block size = 15 , it is works
can possibly use million block size or brute force it
I would like to try to modify the lattice-like use of kangaroo with collision
if not yet understand how it works, can not use it.



I lost my scrypt for collect rsz, I try find it and message additionaly were


Title: Re: lattice-attack || how to run without error
Post by: PrivatePerson on August 29, 2022, 01:29:01 PM
https://github.com/bitlogik/lattice-attack
How do you prepare the list to be loaded into this script?

gen_data.py is make data for use it

run script  gen_data.py
then you got file data.json
and run  lattice_attack.py

or

run script  gen_data.py -f filename
then you got the file filename.json
and run  lattice_attack.py -f filename

I test already if not have a leak nonce it not works
test with a fake nonce leak (random) it never works

gen_data.py - as I understand it generates not real data. I want to insert my rsz (r,s, nonce - if I understood correctly) values collected from the blockchain.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on August 30, 2022, 04:01:28 PM

gen_data.py generate real data. By real, i mean valid ECDSA data. If you want to use own data, you should run gen_data.py and see it's output JSON file to know format data accepted by this tool.

I confirm gen_data.py generate real data. it is the same real RSZ from a real transaction
example  Huobi-wallet   1HckjUpRGcrrRAtFaaCAUaGjsPx9oYmLaZ  million of RSZ
script do same confirm

gen_data.py - as I understand it generates not real data. I want to insert my rsz (r,s, nonce - if I understood correctly) values collected from the blockchain.

just put your own RSZ to JSON format the same  gen_data.py generate data.json

you can use JSON format tools to read JSON data easy
or modify gen_data.py to dump JSON data with indent options will help to read JSON format easy

1. easy manual add, put your own RSZ only by one done.
2. do yourself made script read RSZ and write to JSON format


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on August 30, 2022, 04:12:14 PM

gen_data.py - as I understand it generates not real data. I want to insert my rsz (r,s, nonce - if I understood correctly) values collected from the blockchain.


use JSON Formatter, JSON Beautifier from only
upload data.json to read easy

modify
json.dump(sigs_data, fout)
to
json.dump(sigs_data, fout, indent=3)

add RSZ yourself to replace generated RSZ
you need more than 100 RSZ to calculate
RSZ without leak nonce is useless
try fake nonce leak bit or zero bit is making script error with some loop error
try to use real from some brainwallet (yes we know both private key and nonce)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on August 31, 2022, 12:12:59 AM

gen_data.py - as I understand it generates not real data. I want to insert my rsz (r,s, nonce - if I understood correctly) values collected from the blockchain.


use JSON Formatter, JSON Beautifier from only
upload data.json to read easy

modify
json.dump(sigs_data, fout)
to
json.dump(sigs_data, fout, indent=3)

add RSZ yourself to replace generated RSZ
you need more than 100 RSZ to calculate
RSZ without leak nonce is useless
try fake nonce leak bit or zero bit is making script error with some loop error
try to use real from some brainwallet (yes we know both private key and nonce)

this is real work  ? i was try but unsoccesful.

Can you show real example ?


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on August 31, 2022, 01:46:07 AM

this is real work  ? i was try but unsoccesful.

Can you show real example ?

it not works
I try 100 RSZ
but it did not have real LEAK NONCE
so I try to use zero 0 nonces and try fake leak nonce by random number
I do test fake leak nonce by random number 1 bit to 16 bit
all got error
and error loop infinite
it is never work

maybe the script use nonce point in the right direction
when got the wrong nonce, it is an error

work perfectly only with generating data from script
or you can use some brain wallet leak address (yes, you got to know nonce)

you need a mathematician who can use this lattice attack

I think for lattice attack is interesting
but you need to develop to advance to use it
or maybe focus on one pubkey specific
first, need to develop to can used without leak nonnce

if want to use lattice attack, you need to understand in math of this method
for me too much advance for understanding

this lattice-attack research developer tells already in the video present if they succeed will be rich but if not success here they are present research paper to you know here

just idea impossible you can try using fake nonce random continue until meet but how to know correct leak nonce each
develop some script auto-generate fake nonce and run it loop until found but it needs minimum 100 rsz

kangaroo may be possible and better just need to new way walk to meet key fast



Title: Re: lattice-attack || how to run without error
Post by: casinotester0001 on August 31, 2022, 05:38:38 PM
Can you show real example ?
Good idea!

But I don't know, why I am so important?
@garlonicon

Because you can explain this lattice method in a full example  :)

If you want, create a new thread, call it eg Lattice method explained
Take puzzle 100 data (or something else)
Make a step by step explanation in the OP.
People can ask, contribute and you can edit the OP.

Would be cool  8)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on September 01, 2022, 12:19:36 AM

this is real work  ? i was try but unsoccesful.

Can you show real example ?

it not works
I try 100 RSZ
but it did not have real LEAK NONCE
so I try to use zero 0 nonces and try fake leak nonce by random number
I do test fake leak nonce by random number 1 bit to 16 bit
all got error
and error loop infinite
it is never work

maybe the script use nonce point in the right direction
when got the wrong nonce, it is an error

work perfectly only with generating data from script
or you can use some brain wallet leak address (yes, you got to know nonce)

you need a mathematician who can use this lattice attack

I think for lattice attack is interesting
but you need to develop to advance to use it
or maybe focus on one pubkey specific
first, need to develop to can used without leak nonnce

if want to use lattice attack, you need to understand in math of this method
for me too much advance for understanding

this lattice-attack research developer tells already in the video present if they succeed will be rich but if not success here they are present research paper to you know here

just idea impossible you can try using fake nonce random continue until meet but how to know correct leak nonce each
develop some script auto-generate fake nonce and run it loop until found but it needs minimum 100 rsz

kangaroo may be possible and better just need to new way walk to meet key fast



bro,this is waste of time only.


Title: Re: lattice-attack || how to run without error
Post by: fxsniper on September 01, 2022, 11:13:18 AM

bro, this is waste of time only.

yes, absolute waste of time
I try two times and quite



Title: Re: lattice-attack || how to run without error
Post by: garlonicon on September 02, 2022, 04:41:36 AM
Quote
@garlonicon

Because you can explain this lattice method in a full example  :)

If you want, create a new thread, call it eg Lattice method explained
Take puzzle 100 data (or something else)
Make a step by step explanation in the OP.
People can ask, contribute and you can edit the OP.

Would be cool  8)
Now I only know basic things, like for example how ECDSA works. Understanding how lattices works is ongoing, I need more time to come up with something useful. All what I already know is based on ECDSA properties. For example, if you have a public key, then you can add or subtract any number or public key, or you can multiply and divide it by any known number. And based on that I know that any signature is just a relation between the public key and the "signature public key".
Code:
s=(z+rd)/k
sk=z+rd
sk-z=rd
rd=sk-z
d=(sk-z)/r
d=(s/r)k-(z/r)
d*G=(s/r)*k*G-(z/r)*G
Q=(s/r)*R-(z/r)*G
So, if you have some public key Q, then you can choose some "(z/r)", and then choose some "(r/s)". Just because:
Code:
(Q+(z/r)*G)*(r/s)*G=R
So, you can first choose some "(z/r)", then choose some "(r/s)", then you will get some "R", so you can convert it into "r" by taking "r=R.x", and then you can reach a valid "(r,s,z)" tuple for a given Q. All values will be random, but it doesn't matter for lattice if you have real data from the real blockchain or not. They are random. And the level of your randomness depends on how random is your picked "(z/r)" and "(r/s)", because it is just a linear transformation of adding some number and multiplying by some number to go from Q to R.

But in general, the properties of ECDSA allows you to pick any "(z/r)" and "(r/s)" values. That means, you can create any lattice you want. And then, the quality of your lattice can decide, if you can recover the keys or not, because if they are not random enough, then you will reach nothing. Trying to solve "x=2y" by adding "2x=4y" just won't work, that's why it should be random enough.

So, as you can see, I know ECDSA relations. But the most useful part is still missing, because I still don't know how to construct a proper lattice that would allow recovering some keys. I tried to use that to recover small keys, but my lattices failed for keys with 8 bits, so something is not right and I still have to dig deeper to produce some general solution for lattices.


Title: Re: lattice-attack || how to run without error
Post by: casinotester0001 on September 02, 2022, 10:29:34 AM
Thanks for the explanation.

Now we could take puzzle 100 data, so we can create enough random signatures as we have the private key. And with these signatures, can you explain how the lattice-method works?


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on September 02, 2022, 05:22:22 PM
Quote
Now we could take puzzle 100 data, so we can create enough random signatures as we have the private key.
You can get that quite easily. Just pick any random key and combine it with some mask. For example:
Code:
SHA-256("100-bit")=5f446017ab7a558fae2e58e7a5433ed6d3659024d0e5cb34dd479a80e5395802
              mask=00000000000000000000000000000000000000000000ffffffffffffffffffff
            key100=00000000000000000000000000000000000000000000cb34dd479a80e5395802
Then, you can pretend that you don't know key100, and simply use "key100*G". If you want to produce N signatures, you can do that first, then hide that private key somewhere, and then try to crack your own key. You will get the same problems that you can get when trying to solve the real puzzle, but you will also have the chance to check if you are close enough or not.

Also note that producing any signature is not enough. Because you can obviously use "z/r" equal to "0bad" and "r/s" equal to "c0de", then you can safely assume that your key will have less than 120 bits. But even if you produce hundreds of such signatures, it won't help you, even if your public key and all of your "signature public key" will have a corresponding private key in 120-bit range. It is just not random enough. But on the other hand, if you will produce two random 120-bit signatures, you will probably recover your key. So, the randomness is the key.

Quote
And with these signatures, can you explain how the lattice-method works?
No, because I don't know that yet. Also because I don't think 100-bit keys were broken by lattice attacks. More probably they were beaten by Kangaroo or similar algorithms that don't require valid signatures.


Title: Re: lattice-attack || how to run without error
Post by: casinotester0001 on September 02, 2022, 10:57:23 PM
Quote
And with these signatures, can you explain how the lattice-method works?
No, because I don't know that yet. Also because I don't think 100-bit keys were broken by lattice attacks. More probably they were beaten by Kangaroo or similar algorithms that don't require valid signatures.
I wanted to say, take the 100 bit puzzle data but show how it works with 256 bit. You can create signatures as there is a private key and explain how this lattice method works in the 256 bit range with examples.  :)


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on September 03, 2022, 09:14:02 AM
Firstly if you are talking about lattice attack please be very carefully with definition ot this type attack:)
becouse there is no one "definition" for lattice attack.

Lattice attack can be used only then if we define what we want to take as result. WE have a lot of "lattice attack" types like: CVP, SVP Doubled CVP, and of course mysthic "SLE method". 

all of this lattice attack is designed for something to find. YOU CANT USE "codes" and put there r,s,z without some "modification" to algorithm and waiting for good result.

 
here example:

1.) if we have 1 transaction with remarks:
 privatekey up to 128 bit : with nonce up to 128 bit -> lattice attack will show privatekey

2.) if we have 100 transaction with remarks:
 privatekey up to 2**20 bit : with nonce up to 253 bit -> lattice attack will show privatekey

3.) if we have 480 transaction with remarks:
 privatekey up to 2**10 bit : with nonce up to 254 bit -> lattice attack will show privatekey

4.) if we have 10 transaction with remarks:
 privatekey up to 2**200 bit : with nonce up to 240 bit -> lattice attack will show privatekey


what can we deduct? lattice attack is only bounded result depends the range of privatekeys.

second problem "if you will use" CVP againts SVP you will be have another values.:)



Title: Re: lattice-attack || how to run without error
Post by: casinotester0001 on September 03, 2022, 10:56:37 AM
here example:

1.) if we have 1 transaction with remarks:
 privatekey up to 128 bit : with nonce up to 128 bit -> lattice attack will show privatekey

2.) if we have 100 transaction with remarks:
 privatekey up to 2**20 bit : with nonce up to 253 bit -> lattice attack will show privatekey

3.) if we have 480 transaction with remarks:
 privatekey up to 2**10 bit : with nonce up to 254 bit -> lattice attack will show privatekey

4.) if we have 10 transaction with remarks:
 privatekey up to 2**200 bit : with nonce up to 240 bit -> lattice attack will show privatekey
For 256-bit ECDSA with 8-bit leakage, I guess 50 (even 40) is enough.
source: https://crypto.stackexchange.com/questions/98323/help-breaking-ecdsa-with-biased-nonces (https://crypto.stackexchange.com/questions/98323/help-breaking-ecdsa-with-biased-nonces)


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on September 03, 2022, 12:13:48 PM
Firstly if you are talking about lattice attack please be very carefully with definition ot this type attack:)
becouse there is no one "definition" for lattice attack.

Lattice attack can be used only then if we define what we want to take as result. WE have a lot of "lattice attack" types like: CVP, SVP Doubled CVP, and of course mysthic "SLE method".  

all of this lattice attack is designed for something to find. YOU CANT USE "codes" and put there r,s,z without some "modification" to algorithm and waiting for good result.

 
here example:

1.) if we have 1 transaction with remarks:
 privatekey up to 128 bit : with nonce up to 128 bit -> lattice attack will show privatekey

2.) if we have 100 transaction with remarks:
 privatekey up to 2**20 bit : with nonce up to 253 bit -> lattice attack will show privatekey

3.) if we have 480 transaction with remarks:
 privatekey up to 2**10 bit : with nonce up to 254 bit -> lattice attack will show privatekey

4.) if we have 10 transaction with remarks:
 privatekey up to 2**200 bit : with nonce up to 240 bit -> lattice attack will show privatekey


what can we deduct? lattice attack is only bounded result depends the range of privatekeys.

second problem "if you will use" CVP againts SVP you will be have another values.:)



hi

You was show some yours  results of finding privkey.

i apologise you maybe has more knolage then others. But, no codes for test, and fxsniper , me, and other peoples try and has no results.... so lattice "attack" waste of time for 90% of pioples.


show working code for continue talk...


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 03, 2022, 11:07:52 PM
Can someone post a working python script for basic lattice attack? Thanks


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 04, 2022, 05:44:50 PM
Firstly if you are talking about lattice attack please be very carefully with definition ot this type attack:)
becouse there is no one "definition" for lattice attack.

That's true, but GitHub repository of this tool (lattice-attack) already state what kind of attack it perform.

It uses linear matrices and lattice basis reduction to solve a Shortest Vector Problem from a Hidden Number Problem.



Can someone post a working python script for basic lattice attack? Thanks

If you mean working script besides lattice-attack which mentioned by OP, i only can suggest script from this blog https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/ (https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/).
Did you even read this thread buddy? Both no working OP script and the article you shared is already there and it's useless.

Still waiting for working script...thanks in advance!


Title: Re: lattice-attack || how to run without error
Post by: PrivatePerson on September 04, 2022, 06:56:05 PM
--snip--
gen_data.py - as I understand it generates not real data. I want to insert my rsz (r,s, nonce - if I understood correctly) values collected from the blockchain.

gen_data.py generate real data. By real, i mean valid ECDSA data. If you want to use own data, you should run gen_data.py and see it's output JSON file to know format data accepted by this tool.

I don't understand how it knows which address I want to attack?
Code:
python3 gen_data.py -f data1.json -m "HelloYou" -c SECP256R1 -b 8 -t MSB -n 50
There are many addresses in the blockchain in 100+ transactions, how to check them for weak bits using this attack?
I collected 1000+ rsz from one address, is it possible to use it?
P.S.Sorry for my english, it's very difficult for me to translate.


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on September 05, 2022, 04:33:40 AM
Quote
I don't understand how it knows which address I want to attack?
It doesn't. All things are executed locally. All keys are random and all private keys are known. If you want to attack real keys, you have to change that code, because it is only an example, where all private keys are first generated, and then limited to some range. Then, this generator only can show you that the attack works in practice: for locally generated keys, it can find a solution.

If you want to attack for example 120-bit key, then you have to modify that code. For example I tried using 120-bit "z/r" and 120-bit "r/s". Then, from 120-bit puzzle key, I've got 240-bit nonces. If you add N-bit number with N-bit number, the result has N+1 bits. If you multiply N-bit number by M-bit number, you can get M+N bits. By combining those two rules, your nonces could have: "(bit(119)+bit(119))*bit(120)=bit(120)*bit(120)=bit(240)". Then, after checking 100 random signatures that are guaranteed to have no more than 240 bits, you can see that it doesn't work. It is not random enough. It would work if you could use some 120-bit key, add some 256-bit value, multiply it by another 256-bit value, and somehow reach 240-bit value. But as it is not the case, the randomness in "z/r" and "r/s" is not sufficient to recover any key in that way, because both added and multiplied values are not random enough.


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 12, 2022, 10:41:52 AM
Quote
I don't understand how it knows which address I want to attack?
It doesn't. All things are executed locally. All keys are random and all private keys are known. If you want to attack real keys, you have to change that code, because it is only an example, where all private keys are first generated, and then limited to some range. Then, this generator only can show you that the attack works in practice: for locally generated keys, it can find a solution.

If you want to attack for example 120-bit key, then you have to modify that code. For example I tried using 120-bit "z/r" and 120-bit "r/s". Then, from 120-bit puzzle key, I've got 240-bit nonces. If you add N-bit number with N-bit number, the result has N+1 bits. If you multiply N-bit number by M-bit number, you can get M+N bits. By combining those two rules, your nonces could have: "(bit(119)+bit(119))*bit(120)=bit(120)*bit(120)=bit(240)". Then, after checking 100 random signatures that are guaranteed to have no more than 240 bits, you can see that it doesn't work. It is not random enough. It would work if you could use some 120-bit key, add some 256-bit value, multiply it by another 256-bit value, and somehow reach 240-bit value. But as it is not the case, the randomness in "z/r" and "r/s" is not sufficient to recover any key in that way, because both added and multiplied values are not random enough.
Can you share your modified code?


Title: Re: lattice-attack || how to run without error
Post by: garlonicon on September 12, 2022, 06:11:58 PM
Here is my modified version of "gen_data.py":
Code:
#!/usr/bin/env python3

# Random demo data generator for Lattice ECDSA Attack
# Copyright (C) 2021  Antoine Ferron - BitLogiK
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#

import argparse
import random
import json

import ecdsa_lib

from fpylll import LLL, BKZ, IntegerMatrix

def reduce_lattice(lattice, block_size=None):
    if block_size is None:
        return LLL.reduction(lattice)
    return BKZ.reduction(
        lattice,
        BKZ.Param(
            block_size=block_size,
            strategies=BKZ.DEFAULT_STRATEGY,
            auto_abort=True,
        ),
    )


def test_result(mat, target_pubkey, curve):
    mod_n = ecdsa_lib.curve_n(curve)
    for row in mat:
        candidate = row[-2] % mod_n
        if candidate > 0:
            cand1 = candidate
            cand2 = mod_n - candidate
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand1, curve):
                return cand1
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand2, curve):
                return cand2
    return 0


def build_matrix(sigs, curve, num_bits, bits_type, hash_val):
    num_sigs = len(sigs)
    n_order = ecdsa_lib.curve_n(curve)
    curve_card = 2 ** ecdsa_lib.curve_size(curve)
    lattice = IntegerMatrix(num_sigs + 2, num_sigs + 2)
    kbi = 2 ** num_bits
    inv = ecdsa_lib.inverse_mod
    if hash_val is not None:
        hash_i = hash_val
    if bits_type == "LSB":
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["r"] * inv(sigs[i]["s"], n_order))
                    % n_order
                )
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["kp"] - hash_i * inv(sigs[i]["s"], n_order))
                    % n_order
                )
                + n_order
            )
    else:
        # MSB
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2 * kbi * ((sigs[i]["r"] * inv(sigs[i]["s"], n_order)) % n_order)
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    sigs[i]["kp"] * (curve_card // kbi)
                    - hash_i * inv(sigs[i]["s"], n_order)
                )
                + n_order
            )
    lattice[num_sigs, num_sigs] = 1
    lattice[num_sigs + 1, num_sigs + 1] = n_order
    return lattice


MINIMUM_BITS = 4
RECOVERY_SEQUENCE = [None, 15, 25, 40, 50, 60]
SIGNATURES_NUMBER_MARGIN = 1.03


def minimum_sigs_required(num_bits, curve_name):
    curve_size = ecdsa_lib.curve_size(curve_name)
    return int(SIGNATURES_NUMBER_MARGIN * 4 / 3 * curve_size / num_bits)


def recover_private_key(
    signatures_data, h_int, pub_key, curve, bits_type, num_bits, loop
):

    # Is known bits > 4 ?
    # Change to 5 for 384 and 8 for 521 ?
    if num_bits < MINIMUM_BITS:
        print(
            "This script requires fixed known bits per signature, "
            f"and at least {MINIMUM_BITS}"
        )
        return False

    # Is there enough signatures ?
    n_sigs = minimum_sigs_required(num_bits, curve)
    if n_sigs > len(signatures_data):
        print("Not enough signatures")
        return False

    loop_var = True
    while loop_var:
        sigs_data = random.sample(signatures_data, n_sigs)

        lattice = build_matrix(sigs_data, curve, num_bits, bits_type, h_int)

        for effort in RECOVERY_SEQUENCE:
            lattice = reduce_lattice(lattice, effort)
            res = test_result(lattice, pub_key, curve)
            if res:
                return res
        loop_var = loop
        if loop:
            print("One more try")

    return 0


def lattice_attack_cli(file_name, loop):
    try:
        with open(file_name, "r") as fdata:
            data = json.load(fdata)
    except FileNotFoundError:
        print(f"Data file '{file_name}' was not found.")
        return
    except IOError:
        print(f"Data file {file_name} can't be accessed.")
        return
    except json.JSONDecodeError:
        print("Data file content is not JSON compatible.")
        return
    message = data.get("message")
    if message:
        hash_int = ecdsa_lib.sha2_int(bytes(message))
    else:
        hash_int = None  # Signal to use a hash per sig, sig data
    curve_string = data["curve"]
    data_type = data["known_type"]
    known_bits = data["known_bits"]
    signatures = data["signatures"]
    q_target = data["public_key"]
    if not ecdsa_lib.check_publickey(q_target, curve_string):
        print(
            f"Public key data invalid, not on the given {curve_string.upper()} curve."
        )
        return
    if loop:
        print("Will shuffle loop until the key found.")
    result = recover_private_key(
        signatures, hash_int, q_target, curve_string, data_type, known_bits, loop
    )
    if result:
        return result
    return 0


def get_p_value():
    return 115792089237316195423570985008687907853269984665640564039457584007908834671663


def add_point(px,py,qx,qy):
    if(px==qx):
        return double_point(px,py)
    p_value=get_p_value()
    almost_inverse=qx-px+p_value
    almost_second=qy-py+p_value
    almost_c=(almost_second*ecdsa_lib.inverse_mod(almost_inverse,p_value))
    c=almost_c%p_value
    rx=((c*c)+(2*p_value)-(px+qx))%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]


def double_point(px,py):
    p_value=get_p_value()
    triple_px_square=3*px*px
    double_py=2*py
    inverse_double_py=ecdsa_lib.inverse_mod(double_py,p_value)
    c=(triple_px_square*inverse_double_py)%p_value
    c_square=(c*c)%p_value
    minus_2_px=(2*(p_value-px))%p_value
    rx=(c_square+minus_2_px)%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]   


def multiply_point(px,py,number):
    has_final_point=False
    final_point=[0,0]
    added_point=[px,py]
    while(number!=0):
        if(number%2!=0):
            if not has_final_point:
                final_point=added_point
                has_final_point=True
            else: final_point=add_point(final_point[0],final_point[1],added_point[0],added_point[1])
        number=number//2
        added_point=double_point(added_point[0],added_point[1])
    return final_point


def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16)
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        #print(binaryIndex.hex(),hex(hashedIndex))
        #print(binaryIndex2.hex(),hex(hashedIndex2))
        z_value_with_r=(hashedIndex%puzzle120) #random.randrange(puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120) #random.randrange(puzzle120)
        print(hex(z_value_with_r),hex(r_value_with_s))
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret


if __name__ == "__main__":
    curve="secp256k1"
    n_value=ecdsa_lib.curve_n(curve)
    sigs_data = generates_signatures(curve)
    with open("data.json", "w") as fout:
        json.dump(sigs_data, fout)   
    '''
    d_value=lattice_attack_cli("data.json", False)
    if(d_value==0):
        print("failed")
    else:
        r_value=sigs_data["signatures"][0]["r"]
        s_value=sigs_data["signatures"][0]["s"]
        z_value=sigs_data["signatures"][0]["hash"]
        rd_value=(r_value*d_value)%n_value
        rd_plus_z_value=(rd_value+z_value)%n_value
        inverted_s_value=ecdsa_lib.inverse_mod(s_value,n_value)
        k_value=(rd_plus_z_value*inverted_s_value)%n_value
        print("privkey:",hex(k_value))
    '''
Of course, this code is messy, and it contains things like commented-out code, and some testing code from previous steps. And it is a raw dump of what I left a few months ago. And the most important thing is that it doesn't work, so it should be modified to be usable. But this is what I left before switching to other stuff, because my conclusion was that I need more mathematical knowledge to properly find out, why it fails.


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 14, 2022, 01:11:36 PM
Here is my modified version of "gen_data.py":
Code:
#!/usr/bin/env python3

# Random demo data generator for Lattice ECDSA Attack
# Copyright (C) 2021  Antoine Ferron - BitLogiK
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#

import argparse
import random
import json

import ecdsa_lib

from fpylll import LLL, BKZ, IntegerMatrix

def reduce_lattice(lattice, block_size=None):
    if block_size is None:
        return LLL.reduction(lattice)
    return BKZ.reduction(
        lattice,
        BKZ.Param(
            block_size=block_size,
            strategies=BKZ.DEFAULT_STRATEGY,
            auto_abort=True,
        ),
    )


def test_result(mat, target_pubkey, curve):
    mod_n = ecdsa_lib.curve_n(curve)
    for row in mat:
        candidate = row[-2] % mod_n
        if candidate > 0:
            cand1 = candidate
            cand2 = mod_n - candidate
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand1, curve):
                return cand1
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand2, curve):
                return cand2
    return 0


def build_matrix(sigs, curve, num_bits, bits_type, hash_val):
    num_sigs = len(sigs)
    n_order = ecdsa_lib.curve_n(curve)
    curve_card = 2 ** ecdsa_lib.curve_size(curve)
    lattice = IntegerMatrix(num_sigs + 2, num_sigs + 2)
    kbi = 2 ** num_bits
    inv = ecdsa_lib.inverse_mod
    if hash_val is not None:
        hash_i = hash_val
    if bits_type == "LSB":
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["r"] * inv(sigs[i]["s"], n_order))
                    % n_order
                )
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["kp"] - hash_i * inv(sigs[i]["s"], n_order))
                    % n_order
                )
                + n_order
            )
    else:
        # MSB
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2 * kbi * ((sigs[i]["r"] * inv(sigs[i]["s"], n_order)) % n_order)
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    sigs[i]["kp"] * (curve_card // kbi)
                    - hash_i * inv(sigs[i]["s"], n_order)
                )
                + n_order
            )
    lattice[num_sigs, num_sigs] = 1
    lattice[num_sigs + 1, num_sigs + 1] = n_order
    return lattice


MINIMUM_BITS = 4
RECOVERY_SEQUENCE = [None, 15, 25, 40, 50, 60]
SIGNATURES_NUMBER_MARGIN = 1.03


def minimum_sigs_required(num_bits, curve_name):
    curve_size = ecdsa_lib.curve_size(curve_name)
    return int(SIGNATURES_NUMBER_MARGIN * 4 / 3 * curve_size / num_bits)


def recover_private_key(
    signatures_data, h_int, pub_key, curve, bits_type, num_bits, loop
):

    # Is known bits > 4 ?
    # Change to 5 for 384 and 8 for 521 ?
    if num_bits < MINIMUM_BITS:
        print(
            "This script requires fixed known bits per signature, "
            f"and at least {MINIMUM_BITS}"
        )
        return False

    # Is there enough signatures ?
    n_sigs = minimum_sigs_required(num_bits, curve)
    if n_sigs > len(signatures_data):
        print("Not enough signatures")
        return False

    loop_var = True
    while loop_var:
        sigs_data = random.sample(signatures_data, n_sigs)

        lattice = build_matrix(sigs_data, curve, num_bits, bits_type, h_int)

        for effort in RECOVERY_SEQUENCE:
            lattice = reduce_lattice(lattice, effort)
            res = test_result(lattice, pub_key, curve)
            if res:
                return res
        loop_var = loop
        if loop:
            print("One more try")

    return 0


def lattice_attack_cli(file_name, loop):
    try:
        with open(file_name, "r") as fdata:
            data = json.load(fdata)
    except FileNotFoundError:
        print(f"Data file '{file_name}' was not found.")
        return
    except IOError:
        print(f"Data file {file_name} can't be accessed.")
        return
    except json.JSONDecodeError:
        print("Data file content is not JSON compatible.")
        return
    message = data.get("message")
    if message:
        hash_int = ecdsa_lib.sha2_int(bytes(message))
    else:
        hash_int = None  # Signal to use a hash per sig, sig data
    curve_string = data["curve"]
    data_type = data["known_type"]
    known_bits = data["known_bits"]
    signatures = data["signatures"]
    q_target = data["public_key"]
    if not ecdsa_lib.check_publickey(q_target, curve_string):
        print(
            f"Public key data invalid, not on the given {curve_string.upper()} curve."
        )
        return
    if loop:
        print("Will shuffle loop until the key found.")
    result = recover_private_key(
        signatures, hash_int, q_target, curve_string, data_type, known_bits, loop
    )
    if result:
        return result
    return 0


def get_p_value():
    return 115792089237316195423570985008687907853269984665640564039457584007908834671663


def add_point(px,py,qx,qy):
    if(px==qx):
        return double_point(px,py)
    p_value=get_p_value()
    almost_inverse=qx-px+p_value
    almost_second=qy-py+p_value
    almost_c=(almost_second*ecdsa_lib.inverse_mod(almost_inverse,p_value))
    c=almost_c%p_value
    rx=((c*c)+(2*p_value)-(px+qx))%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]


def double_point(px,py):
    p_value=get_p_value()
    triple_px_square=3*px*px
    double_py=2*py
    inverse_double_py=ecdsa_lib.inverse_mod(double_py,p_value)
    c=(triple_px_square*inverse_double_py)%p_value
    c_square=(c*c)%p_value
    minus_2_px=(2*(p_value-px))%p_value
    rx=(c_square+minus_2_px)%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]   


def multiply_point(px,py,number):
    has_final_point=False
    final_point=[0,0]
    added_point=[px,py]
    while(number!=0):
        if(number%2!=0):
            if not has_final_point:
                final_point=added_point
                has_final_point=True
            else: final_point=add_point(final_point[0],final_point[1],added_point[0],added_point[1])
        number=number//2
        added_point=double_point(added_point[0],added_point[1])
    return final_point


def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16)
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        #print(binaryIndex.hex(),hex(hashedIndex))
        #print(binaryIndex2.hex(),hex(hashedIndex2))
        z_value_with_r=(hashedIndex%puzzle120) #random.randrange(puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120) #random.randrange(puzzle120)
        print(hex(z_value_with_r),hex(r_value_with_s))
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret


if __name__ == "__main__":
    curve="secp256k1"
    n_value=ecdsa_lib.curve_n(curve)
    sigs_data = generates_signatures(curve)
    with open("data.json", "w") as fout:
        json.dump(sigs_data, fout)   
    '''
    d_value=lattice_attack_cli("data.json", False)
    if(d_value==0):
        print("failed")
    else:
        r_value=sigs_data["signatures"][0]["r"]
        s_value=sigs_data["signatures"][0]["s"]
        z_value=sigs_data["signatures"][0]["hash"]
        rd_value=(r_value*d_value)%n_value
        rd_plus_z_value=(rd_value+z_value)%n_value
        inverted_s_value=ecdsa_lib.inverse_mod(s_value,n_value)
        k_value=(rd_plus_z_value*inverted_s_value)%n_value
        print("privkey:",hex(k_value))
    '''
Of course, this code is messy, and it contains things like commented-out code, and some testing code from previous steps. And it is a raw dump of what I left a few months ago. And the most important thing is that it doesn't work, so it should be modified to be usable. But this is what I left before switching to other stuff, because my conclusion was that I need more mathematical knowledge to properly find out, why it fails.

Thanks for sharing, but I this code is too much for me, can't get it to work.
I hope someone will sort it out soon and explain the attack in a understandable way


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on September 14, 2022, 07:17:20 PM
Here is my modified version of "gen_data.py":
Code:
#!/usr/bin/env python3

# Random demo data generator for Lattice ECDSA Attack
# Copyright (C) 2021  Antoine Ferron - BitLogiK
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#

import argparse
import random
import json

import ecdsa_lib

from fpylll import LLL, BKZ, IntegerMatrix

def reduce_lattice(lattice, block_size=None):
    if block_size is None:
        return LLL.reduction(lattice)
    return BKZ.reduction(
        lattice,
        BKZ.Param(
            block_size=block_size,
            strategies=BKZ.DEFAULT_STRATEGY,
            auto_abort=True,
        ),
    )


def test_result(mat, target_pubkey, curve):
    mod_n = ecdsa_lib.curve_n(curve)
    for row in mat:
        candidate = row[-2] % mod_n
        if candidate > 0:
            cand1 = candidate
            cand2 = mod_n - candidate
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand1, curve):
                return cand1
            if target_pubkey == ecdsa_lib.privkey_to_pubkey(cand2, curve):
                return cand2
    return 0


def build_matrix(sigs, curve, num_bits, bits_type, hash_val):
    num_sigs = len(sigs)
    n_order = ecdsa_lib.curve_n(curve)
    curve_card = 2 ** ecdsa_lib.curve_size(curve)
    lattice = IntegerMatrix(num_sigs + 2, num_sigs + 2)
    kbi = 2 ** num_bits
    inv = ecdsa_lib.inverse_mod
    if hash_val is not None:
        hash_i = hash_val
    if bits_type == "LSB":
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["r"] * inv(sigs[i]["s"], n_order))
                    % n_order
                )
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    inv(kbi, n_order)
                    * (sigs[i]["kp"] - hash_i * inv(sigs[i]["s"], n_order))
                    % n_order
                )
                + n_order
            )
    else:
        # MSB
        for i in range(num_sigs):
            lattice[i, i] = 2 * kbi * n_order
            if hash_val is None:
                hash_i = sigs[i]["hash"]
            lattice[num_sigs, i] = (
                2 * kbi * ((sigs[i]["r"] * inv(sigs[i]["s"], n_order)) % n_order)
            )
            lattice[num_sigs + 1, i] = (
                2
                * kbi
                * (
                    sigs[i]["kp"] * (curve_card // kbi)
                    - hash_i * inv(sigs[i]["s"], n_order)
                )
                + n_order
            )
    lattice[num_sigs, num_sigs] = 1
    lattice[num_sigs + 1, num_sigs + 1] = n_order
    return lattice


MINIMUM_BITS = 4
RECOVERY_SEQUENCE = [None, 15, 25, 40, 50, 60]
SIGNATURES_NUMBER_MARGIN = 1.03


def minimum_sigs_required(num_bits, curve_name):
    curve_size = ecdsa_lib.curve_size(curve_name)
    return int(SIGNATURES_NUMBER_MARGIN * 4 / 3 * curve_size / num_bits)


def recover_private_key(
    signatures_data, h_int, pub_key, curve, bits_type, num_bits, loop
):

    # Is known bits > 4 ?
    # Change to 5 for 384 and 8 for 521 ?
    if num_bits < MINIMUM_BITS:
        print(
            "This script requires fixed known bits per signature, "
            f"and at least {MINIMUM_BITS}"
        )
        return False

    # Is there enough signatures ?
    n_sigs = minimum_sigs_required(num_bits, curve)
    if n_sigs > len(signatures_data):
        print("Not enough signatures")
        return False

    loop_var = True
    while loop_var:
        sigs_data = random.sample(signatures_data, n_sigs)

        lattice = build_matrix(sigs_data, curve, num_bits, bits_type, h_int)

        for effort in RECOVERY_SEQUENCE:
            lattice = reduce_lattice(lattice, effort)
            res = test_result(lattice, pub_key, curve)
            if res:
                return res
        loop_var = loop
        if loop:
            print("One more try")

    return 0


def lattice_attack_cli(file_name, loop):
    try:
        with open(file_name, "r") as fdata:
            data = json.load(fdata)
    except FileNotFoundError:
        print(f"Data file '{file_name}' was not found.")
        return
    except IOError:
        print(f"Data file {file_name} can't be accessed.")
        return
    except json.JSONDecodeError:
        print("Data file content is not JSON compatible.")
        return
    message = data.get("message")
    if message:
        hash_int = ecdsa_lib.sha2_int(bytes(message))
    else:
        hash_int = None  # Signal to use a hash per sig, sig data
    curve_string = data["curve"]
    data_type = data["known_type"]
    known_bits = data["known_bits"]
    signatures = data["signatures"]
    q_target = data["public_key"]
    if not ecdsa_lib.check_publickey(q_target, curve_string):
        print(
            f"Public key data invalid, not on the given {curve_string.upper()} curve."
        )
        return
    if loop:
        print("Will shuffle loop until the key found.")
    result = recover_private_key(
        signatures, hash_int, q_target, curve_string, data_type, known_bits, loop
    )
    if result:
        return result
    return 0


def get_p_value():
    return 115792089237316195423570985008687907853269984665640564039457584007908834671663


def add_point(px,py,qx,qy):
    if(px==qx):
        return double_point(px,py)
    p_value=get_p_value()
    almost_inverse=qx-px+p_value
    almost_second=qy-py+p_value
    almost_c=(almost_second*ecdsa_lib.inverse_mod(almost_inverse,p_value))
    c=almost_c%p_value
    rx=((c*c)+(2*p_value)-(px+qx))%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]


def double_point(px,py):
    p_value=get_p_value()
    triple_px_square=3*px*px
    double_py=2*py
    inverse_double_py=ecdsa_lib.inverse_mod(double_py,p_value)
    c=(triple_px_square*inverse_double_py)%p_value
    c_square=(c*c)%p_value
    minus_2_px=(2*(p_value-px))%p_value
    rx=(c_square+minus_2_px)%p_value
    ry=(c*(px-rx+p_value)+p_value-py)%p_value
    return [rx,ry]    


def multiply_point(px,py,number):
    has_final_point=False
    final_point=[0,0]
    added_point=[px,py]
    while(number!=0):
        if(number%2!=0):
            if not has_final_point:
                final_point=added_point
                has_final_point=True
            else: final_point=add_point(final_point[0],final_point[1],added_point[0],added_point[1])
        number=number//2
        added_point=double_point(added_point[0],added_point[1])
    return final_point


def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16)
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        #print(binaryIndex.hex(),hex(hashedIndex))
        #print(binaryIndex2.hex(),hex(hashedIndex2))
        z_value_with_r=(hashedIndex%puzzle120) #random.randrange(puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120) #random.randrange(puzzle120)
        print(hex(z_value_with_r),hex(r_value_with_s))
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret


if __name__ == "__main__":
    curve="secp256k1"
    n_value=ecdsa_lib.curve_n(curve)
    sigs_data = generates_signatures(curve)
    with open("data.json", "w") as fout:
        json.dump(sigs_data, fout)    
    '''
    d_value=lattice_attack_cli("data.json", False)
    if(d_value==0):
        print("failed")
    else:
        r_value=sigs_data["signatures"][0]["r"]
        s_value=sigs_data["signatures"][0]["s"]
        z_value=sigs_data["signatures"][0]["hash"]
        rd_value=(r_value*d_value)%n_value
        rd_plus_z_value=(rd_value+z_value)%n_value
        inverted_s_value=ecdsa_lib.inverse_mod(s_value,n_value)
        k_value=(rd_plus_z_value*inverted_s_value)%n_value
        print("privkey:",hex(k_value))
    '''
Of course, this code is messy, and it contains things like commented-out code, and some testing code from previous steps. And it is a raw dump of what I left a few months ago. And the most important thing is that it doesn't work, so it should be modified to be usable. But this is what I left before switching to other stuff, because my conclusion was that I need more mathematical knowledge to properly find out, why it fails.

Bro, can try talk with  Antoine Ferron - BitLogiK at his github ? I think he can help modify code to working condition ???

https://github.com/bitlogik/lattice-attack/issues

ps a I was talk  with him previously, he is ansver to queschion. Becausd I dont know what exact scrypt do, for me hard will talk with him...


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 15, 2022, 04:54:35 PM

Bro, can try talk with  Antoine Ferron - BitLogiK at his github ? I think he can help modify code to working condition ???

https://github.com/bitlogik/lattice-attack/issues

ps a I was talk  with him previously, he is ansver to queschion. Becausd I dont know what exact scrypt do, for me hard will talk with him...

That's actually a great idea, if you guys want we could offer the creator some $ to edit the code.


Title: Re: lattice-attack || how to run without error
Post by: ecdsa123 on September 15, 2022, 05:04:01 PM
I can rewrite those code , for easy and understanding -> python with sage version


my propose $100 on my btc account, of course before start work


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on September 15, 2022, 07:50:56 PM

Bro, can try talk with  Antoine Ferron - BitLogiK at his github ? I think he can help modify code to working condition ???

https://github.com/bitlogik/lattice-attack/issues

ps a I was talk  with him previously, he is ansver to queschion. Becausd I dont know what exact scrypt do, for me hard will talk with him...

That's actually a great idea, if you guys want we could offer the creator some $ to edit the code.



For talk about $$ for coder of original scrypt for rsz generation, we need to know, what is difference of original and modified versions of scrypt, and what not work in the scrypt.

May be this is imposible to solve ... unfortunately.

I have a telegramm of original scrypt developer, and first of all we ned try ask him for free help and message post to devevrloper iesues in github on link what I provide previously in this thread.


???

br


Title: Re: lattice-attack || how to run without error
Post by: COBRAS on September 15, 2022, 07:52:55 PM
I can rewrite those code , for easy and understanding -> python with sage version


my propose $100 on my btc account, of course before start work

and waht will be your new code doing ? generate sighnatures like original  scrypt without rial world use posibble ?

br


Title: Re: lattice-attack || how to run without error
Post by: BHWallet on September 16, 2022, 09:35:01 AM

Bro, can try talk with  Antoine Ferron - BitLogiK at his github ? I think he can help modify code to working condition ???

https://github.com/bitlogik/lattice-attack/issues

ps a I was talk  with him previously, he is ansver to queschion. Becausd I dont know what exact scrypt do, for me hard will talk with him...

That's actually a great idea, if you guys want we could offer the creator some $ to edit the code.



For talk about $$ for coder of original scrypt for rsz generation, we need to know, what is difference of original and modified versions of scrypt, and what not work in the scrypt.

May be this is imposible to solve ... unfortunately.

I have a telegramm of original scrypt developer, and first of all we ned try ask him for free help and message post to devevrloper iesues in github on link what I provide previously in this thread.


???

br

Just ask him can he edit the script in such a way that the user is able to paste a list of public keys or addresses and the script will go through that list and search for weaknesses.
You can invite the creator to this thread.


Title: Re: lattice-attack || how to run without error
Post by: PrivatePerson on October 19, 2022, 08:20:49 PM
If I understand correctly from the answers on github, the creator does not want to change his code.


Title: Re: lattice-attack || how to run without error
Post by: krashfire on November 08, 2022, 04:33:06 PM
First, we look at signatures:
Code:
s=(z+rd)/k
sk=z+rd
sk-z=rd
(sk-z)/r=d
(s/r)k-(z/r)=d
(z/r)+d=(s/r)k
k=((z/r)+d)*(r/s)
Then, things are quite simple:
Code:
z/r=random
r/s=random
But we can do more than that:
Code:
z/r=120_bit_number_v1
r/s=120_bit_number_v2
k=(120_bit_number_v1+d)*120_bit_number_v2
If "d" is our 120_bit_privkey, then first we add another 120_bit number to that (we can use 119-bit numbers to be 100% sure). Then, we have 121-bit number at most, it cannot be bigger. And if we multiply that by another 119-bit number (just to be sure), then we will have 121+119=240 bits in our result. It cannot be bigger than that, because if you multiply M-bit number by N-bit number, then the result has at most M+N bits. So, in this way I can be absolutely sure that if "d" is a 120-bit number, then "k" is a 240-bit number. In the same way, it is possible to generate many signatures with many different N-bit values. But it is still not enough to use that in a lattice attack, because it needs some randomness in the right places, so something else is also needed to make it.

Edit:
Quote
show your code
Code:
def generates_signatures(curve):
    puzzle120=int("00000000000000000000000000000000007fffffffffffffffffffffffffffff",16) #119-bit to be 100% sure to not fall into 241-bit range
    known_bits=16
    n_value=ecdsa_lib.curve_n(curve)
    Q_point=[93499419120076195219278579763555015417347613618260420189054155605804414805552,19494200143356336257404688340550956357466777176798681646526975620299854296492]
    sigs = []
    for index in range(100):
        binaryIndex=(index*2).to_bytes(32,'big')
        binaryIndex2=(index*2+1).to_bytes(32,'big')
        hashedIndex=ecdsa_lib.sha2_int(binaryIndex)
        hashedIndex2=ecdsa_lib.sha2_int(binaryIndex2)
        z_value_with_r=(hashedIndex%puzzle120)
        added_point=ecdsa_lib.privkey_to_pubkey(z_value_with_r,curve)
        final_point=add_point(Q_point[0],Q_point[1],added_point[0],added_point[1])
        r_value_with_s=(hashedIndex2%puzzle120)
        R_point=multiply_point(final_point[0],final_point[1],r_value_with_s)
        r_value=R_point[0]
        s_value_with_r=ecdsa_lib.inverse_mod(r_value_with_s,n_value)
        s_value=(s_value_with_r*r_value)%n_value
        z_value=(z_value_with_r*r_value)%n_value
        sigs.append(
            {
                "r": r_value,
                "s": s_value,
                "kp": 0,
                "hash": z_value
            }
        )
    ret = {
        "curve": curve.upper(),
        "public_key": Q_point,
        "known_type": "MSB",
        "known_bits": known_bits,
        "signatures": sigs,
    }
    return ret

I tested your code. I believe the output gave several R and S value. I wish you had continue finishing the script. Z value and Kp didn't come out. What do I need to add in the script so that the Z_hash value and kp can be output?


Title: Re: lattice-attack || how to run without error
Post by: krashfire on December 04, 2022, 12:50:08 PM

Some problems with install fpylll

Developer using Ubuntu >= 20.04
So try on Ubuntu 20.04

pip install git+https://github.com/bitlogik/lattice-attack
pip install git+https://github.com/fplll/fpylll.git

All command try installs not successful both on os windows and Linux

using conda not successful too
conda install -c conda-forge fpylll

all methods include update apt too

sudo add-apt-repository universe
sudo apt update
sudo apt install python3-fpylll

pip install Cython

all fail


remove sagemath and it will work. somehow fpylll clash with sagemath and it does not run properly. removing sagemath will solve your issue. in debian,
#apt remove sagemath
#apt update

then run your lattice_attack.py again.


Title: Re: lattice-attack || how to run without error
Post by: vhh on January 31, 2023, 07:07:15 PM
If I understand correctly from the answers on github, the creator does not want to change his code.


Well, the code is working as it should, so why should he change it? It finds the priv key from multiple signatures, when some LSB or MSB of each signature nonce is leaked.


Title: Re: lattice-attack || how to run without error
Post by: Bglhn on March 18, 2024, 11:09:26 AM
Hello friends. I've been trying to learn for a while. Where and how do you find the known bit value and Lbs/mbs? No matter what I did, I could not perform a successful lattice attack. I'm sorry for my English and my inexperience. I'm trying to learn.