Bitcoin Forum
November 08, 2024, 08:12:19 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Create 100 R,s,z signatures from public key  (Read 194 times)
krashfire (OP)
Member
**
Offline Offline

Activity: 127
Merit: 14

Life aint interesting without any cuts and bruises


View Profile
February 07, 2023, 10:20:15 AM
Last edit: February 07, 2023, 10:44:20 AM by krashfire
 #1

 Python code for those of you who are looking to create 100 or more R,s,z signatures. The sigs are created via the public key.

However, it is important to note that these signatures would not be unique and would not have any real-world meaning or value. Here is an example in Python using the cryptography library:

Code:

import os
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec

private_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
public_key = private_key.public_key()

for i in range(100):
    data = os.urandom(32)
    signature = private_key.sign(data, ec.ECDSA(hashes.SHA256()))

    # Extract the values of 'r', 's', 'z' from the signature
    r, s = signature
    z = int.from_bytes(hashlib.sha256(data).digest(), 'big')

    # Print the values of 'r', 's', 'z'
    print("r:", r)
    print("s:", s)
    print("z:", z)  


If you need to make more, change the 100 here to any amount you need.

Code:
for i in range(100):

Just giving you guys a little help.

Cheers.

And here is the code to generate 100 signatures with k nonce reveal.

Code:
 

import ecdsa
import random

# Define the secp256k1 curve
curve = ecdsa.SECP256k1

# Generate 100 random private keys
private_keys = [ecdsa.SigningKey.generate(curve=curve) for i in range(100)]

# Create signatures using the private keys and random messages (z)
signatures = []
for i in range(100):
    z = random.randint(0, 2**256)
    private_key = private_keys[i]
    public_key = private_key.get_verifying_key()
    signature = private_key.sign_digest(z.to_bytes(32, 'big'), sigencode=ecdsa.util.sigencode_der)
    r, s = ecdsa.util.sigdecode_der(signature, curve.generator.order())
    signatures.append((z, r, s))

# Get the nonce (k) for each signature
nonce = []
for i in range(100):
    z, r, s = signatures[i]
    k = ecdsa. SigningKey.from_public_key(public_key, curve=curve).verifying_key.recover_session_key(z.to_bytes(32, 'big'), (r, s), hashfunc=ecdsa.util.sha256, sigdecode=ecdsa.util.sigdecode_der)
    nonce.append(k)

# The 100 signatures, Z values, and nonce values are stored in the signatures, Z, and nonce lists, respectively.

 

KRASH
Yoshimaka
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
February 07, 2023, 01:51:56 PM
 #2

Python code for those of you who are looking to create 100 or more R,s,z signatures. The sigs are created via the public key.

However, it is important to note that these signatures would not be unique and would not have any real-world meaning or value. Here is an example in Python using the cryptography library:

Code:

import os
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec

private_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
public_key = private_key.public_key()

for i in range(100):
    data = os.urandom(32)
    signature = private_key.sign(data, ec.ECDSA(hashes.SHA256()))

    # Extract the values of 'r', 's', 'z' from the signature
    r, s = signature
    z = int.from_bytes(hashlib.sha256(data).digest(), 'big')

    # Print the values of 'r', 's', 'z'
    print("r:", r)
    print("s:", s)
    print("z:", z)  


If you need to make more, change the 100 here to any amount you need.

Code:
for i in range(100):

Just giving you guys a little help.

Cheers.

And here is the code to generate 100 signatures with k nonce reveal.

Code:
 

import ecdsa
import random

# Define the secp256k1 curve
curve = ecdsa.SECP256k1

# Generate 100 random private keys
private_keys = [ecdsa.SigningKey.generate(curve=curve) for i in range(100)]

# Create signatures using the private keys and random messages (z)
signatures = []
for i in range(100):
    z = random.randint(0, 2**256)
    private_key = private_keys[i]
    public_key = private_key.get_verifying_key()
    signature = private_key.sign_digest(z.to_bytes(32, 'big'), sigencode=ecdsa.util.sigencode_der)
    r, s = ecdsa.util.sigdecode_der(signature, curve.generator.order())
    signatures.append((z, r, s))

# Get the nonce (k) for each signature
nonce = []
for i in range(100):
    z, r, s = signatures[i]
    k = ecdsa. SigningKey.from_public_key(public_key, curve=curve).verifying_key.recover_session_key(z.to_bytes(32, 'big'), (r, s), hashfunc=ecdsa.util.sha256, sigdecode=ecdsa.util.sigdecode_der)
    nonce.append(k)

# The 100 signatures, Z values, and nonce values are stored in the signatures, Z, and nonce lists, respectively.

 
What purpose does it serve? Are you trying to solve ECC problem by signature attack? What is your academic background on cryptography?
COBRAS
Member
**
Offline Offline

Activity: 1017
Merit: 23


View Profile
February 07, 2023, 05:30:37 PM
Last edit: February 07, 2023, 08:17:20 PM by COBRAS
 #3

Python code for those of you who are looking to create 100 or more R,s,z signatures. The sigs are created via the public key.

However, it is important to note that these signatures would not be unique and would not have any real-world meaning or value. Here is an example in Python using the cryptography library:

Code:

import os
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec

private_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
public_key = private_key.public_key()

for i in range(100):
    data = os.urandom(32)
    signature = private_key.sign(data, ec.ECDSA(hashes.SHA256()))

    # Extract the values of 'r', 's', 'z' from the signature
    r, s = signature
    z = int.from_bytes(hashlib.sha256(data).digest(), 'big')

    # Print the values of 'r', 's', 'z'
    print("r:", r)
    print("s:", s)
    print("z:", z)  


If you need to make more, change the 100 here to any amount you need.

Code:
for i in range(100):

Just giving you guys a little help.

Cheers.

And here is the code to generate 100 signatures with k nonce reveal.

Code:
 

import ecdsa
import random

# Define the secp256k1 curve
curve = ecdsa.SECP256k1

# Generate 100 random private keys
private_keys = [ecdsa.SigningKey.generate(curve=curve) for i in range(100)]

# Create signatures using the private keys and random messages (z)
signatures = []
for i in range(100):
    z = random.randint(0, 2**256)
    private_key = private_keys[i]
    public_key = private_key.get_verifying_key()
    signature = private_key.sign_digest(z.to_bytes(32, 'big'), sigencode=ecdsa.util.sigencode_der)
    r, s = ecdsa.util.sigdecode_der(signature, curve.generator.order())
    signatures.append((z, r, s))

# Get the nonce (k) for each signature
nonce = []
for i in range(100):
    z, r, s = signatures[i]
    k = ecdsa. SigningKey.from_public_key(public_key, curve=curve).verifying_key.recover_session_key(z.to_bytes(32, 'big'), (r, s), hashfunc=ecdsa.util.sha256, sigdecode=ecdsa.util.sigdecode_der)
    nonce.append(k)

# The 100 signatures, Z values, and nonce values are stored in the signatures, Z, and nonce lists, respectively.

 

Bro can you make a code for sigh with enother curve with enother order and another base point ? This curve is a twist of secp256k1

data of a curve:


p = 115792089237316195423570985008687907853269984665640564039457584007908834671663

E1 = EllipticCurve(GF(p), [0,1])


data of a Bae Point P11 = E1([85121563011366687025707822879925964033143920255507899862530934382179124106759, 42409656727948788569510737393982221864295921023467166630061319157315739523945])

Data of curve order:
ord11 = 20412485227

?


If you make this code maybee our R os S will be poin at a TWIST

additional info about twit

https://cryptodeeptech.ru/twist-attack/



[
krashfire (OP)
Member
**
Offline Offline

Activity: 127
Merit: 14

Life aint interesting without any cuts and bruises


View Profile
February 07, 2023, 08:48:37 PM
 #4

Python code for those of you who are looking to create 100 or more R,s,z signatures. The sigs are created via the public key.

However, it is important to note that these signatures would not be unique and would not have any real-world meaning or value. Here is an example in Python using the cryptography library:

Code:

import os
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec

private_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
public_key = private_key.public_key()

for i in range(100):
    data = os.urandom(32)
    signature = private_key.sign(data, ec.ECDSA(hashes.SHA256()))

    # Extract the values of 'r', 's', 'z' from the signature
    r, s = signature
    z = int.from_bytes(hashlib.sha256(data).digest(), 'big')

    # Print the values of 'r', 's', 'z'
    print("r:", r)
    print("s:", s)
    print("z:", z)   


If you need to make more, change the 100 here to any amount you need.

Code:
for i in range(100):

Just giving you guys a little help.

Cheers.

And here is the code to generate 100 signatures with k nonce reveal.

Code:
 

import ecdsa
import random

# Define the secp256k1 curve
curve = ecdsa.SECP256k1

# Generate 100 random private keys
private_keys = [ecdsa.SigningKey.generate(curve=curve) for i in range(100)]

# Create signatures using the private keys and random messages (z)
signatures = []
for i in range(100):
    z = random.randint(0, 2**256)
    private_key = private_keys[i]
    public_key = private_key.get_verifying_key()
    signature = private_key.sign_digest(z.to_bytes(32, 'big'), sigencode=ecdsa.util.sigencode_der)
    r, s = ecdsa.util.sigdecode_der(signature, curve.generator.order())
    signatures.append((z, r, s))

# Get the nonce (k) for each signature
nonce = []
for i in range(100):
    z, r, s = signatures[i]
    k = ecdsa. SigningKey.from_public_key(public_key, curve=curve).verifying_key.recover_session_key(z.to_bytes(32, 'big'), (r, s), hashfunc=ecdsa.util.sha256, sigdecode=ecdsa.util.sigdecode_der)
    nonce.append(k)

# The 100 signatures, Z values, and nonce values are stored in the signatures, Z, and nonce lists, respectively.

 

Bro can you make a code for sigh with enother curve with enother order and another base point ? This curve is a twist of secp256k1

data of a curve:


p = 115792089237316195423570985008687907853269984665640564039457584007908834671663

E1 = EllipticCurve(GF(p), [0,1])


data of a Bae Point P11 = E1([85121563011366687025707822879925964033143920255507899862530934382179124106759, 42409656727948788569510737393982221864295921023467166630061319157315739523945])

Data of curve order:
ord11 = 20412485227

?


If you make this code maybee our R os S will be poin at a TWIST

additional info about twit

https://cryptodeeptech.ru/twist-attack/



sure bro. give me a day or 2. i get back to you on the post here.

KRASH
COBRAS
Member
**
Offline Offline

Activity: 1017
Merit: 23


View Profile
February 07, 2023, 09:09:47 PM
 #5

Python code for those of you who are looking to create 100 or more R,s,z signatures. The sigs are created via the public key.

However, it is important to note that these signatures would not be unique and would not have any real-world meaning or value. Here is an example in Python using the cryptography library:

Code:

import os
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec

private_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
public_key = private_key.public_key()

for i in range(100):
    data = os.urandom(32)
    signature = private_key.sign(data, ec.ECDSA(hashes.SHA256()))

    # Extract the values of 'r', 's', 'z' from the signature
    r, s = signature
    z = int.from_bytes(hashlib.sha256(data).digest(), 'big')

    # Print the values of 'r', 's', 'z'
    print("r:", r)
    print("s:", s)
    print("z:", z)   


If you need to make more, change the 100 here to any amount you need.

Code:
for i in range(100):

Just giving you guys a little help.

Cheers.

And here is the code to generate 100 signatures with k nonce reveal.

Code:
 

import ecdsa
import random

# Define the secp256k1 curve
curve = ecdsa.SECP256k1

# Generate 100 random private keys
private_keys = [ecdsa.SigningKey.generate(curve=curve) for i in range(100)]

# Create signatures using the private keys and random messages (z)
signatures = []
for i in range(100):
    z = random.randint(0, 2**256)
    private_key = private_keys[i]
    public_key = private_key.get_verifying_key()
    signature = private_key.sign_digest(z.to_bytes(32, 'big'), sigencode=ecdsa.util.sigencode_der)
    r, s = ecdsa.util.sigdecode_der(signature, curve.generator.order())
    signatures.append((z, r, s))

# Get the nonce (k) for each signature
nonce = []
for i in range(100):
    z, r, s = signatures[i]
    k = ecdsa. SigningKey.from_public_key(public_key, curve=curve).verifying_key.recover_session_key(z.to_bytes(32, 'big'), (r, s), hashfunc=ecdsa.util.sha256, sigdecode=ecdsa.util.sigdecode_der)
    nonce.append(k)

# The 100 signatures, Z values, and nonce values are stored in the signatures, Z, and nonce lists, respectively.

 

Bro can you make a code for sigh with enother curve with enother order and another base point ? This curve is a twist of secp256k1

data of a curve:


p = 115792089237316195423570985008687907853269984665640564039457584007908834671663

E1 = EllipticCurve(GF(p), [0,1])


data of a Bae Point P11 = E1([85121563011366687025707822879925964033143920255507899862530934382179124106759, 42409656727948788569510737393982221864295921023467166630061319157315739523945])

Data of curve order:
ord11 = 20412485227

?


If you make this code maybee our R os S will be poin at a TWIST

additional info about twit

https://cryptodeeptech.ru/twist-attack/



sure bro. give me a day or 2. i get back to you on the post here.

Great bro. For move bitcoin to twist we need multiply privkey to base point from a twist, OR, multiply pubkey to privkey of base point(or privkey  pubkey or (base point / 2) of a twist. but I dont uberstand on wahet curve do it on scep256k1( ie ... +7) or curve of a twist (... +1 this curve param I was send you at myprevious post) I continue thinking how to do. Waiting you code for test.

thx

[
COBRAS
Member
**
Offline Offline

Activity: 1017
Merit: 23


View Profile
February 07, 2023, 10:55:29 PM
 #6

enother formula

https://learn.saylor.org/mod/book/view.php?id=36341&chapterid=18920



P = S-1*Hash(m) *G+S-1*R*Qa

P is a publick key

how to replace G and Qa to this

"Bae Point P11" from my previous post does we get point on a twist ?




[
krashfire (OP)
Member
**
Offline Offline

Activity: 127
Merit: 14

Life aint interesting without any cuts and bruises


View Profile
February 07, 2023, 11:27:36 PM
 #7

Twist attack formula. I understood now. Let me code it but cannot be done on Python. Too slow. Will do in C Or Go Lang. I will figure it out. Get back to you.

KRASH
COBRAS
Member
**
Offline Offline

Activity: 1017
Merit: 23


View Profile
February 07, 2023, 11:30:46 PM
 #8

Twist attack formula. I understood now. Let me code it but cannot be done on Python. Too slow. Will do in C Or Go Lang. I will figure it out. Get back to you.

no bro !

[
COBRAS
Member
**
Offline Offline

Activity: 1017
Merit: 23


View Profile
February 08, 2023, 05:09:13 AM
 #9

resource with low level EC and ECDSA formulas

add,mul,curve,sign etc

https://onyb.gitbook.io/secp256k1-python/ecdsa

[
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!