logo AnonDrop.NET Recreate Key

Recreate Decryption Key

This page explains how to recreate your decryption key from a file key. This process involves four main steps, each with its own Python script.

1. Generate Seed

The first step is to generate a seed. This is done using the current timestamp.


import datetime

def seed_gen():
    EPOCH = 1420070400000
    current_timestamp_ms = int(datetime.datetime.now(datetime.timezone.utc).timestamp() * 1000)
    snowflake_id = (current_timestamp_ms - EPOCH) << 22
    return snowflake_id
                

2. Generate Private Key

Using the generated seed, we can now create a private key. This key will be used to derive the public key.


import random

def generate_private_key(seed):
    N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
    
    random.seed(seed)
    
    private_key_int = random.randrange(1, N)
    private_key_hex = format(private_key_int, '064x')
    
    return private_key_hex
                

3. Create Public Key

From the private key, we can generate the public key. This public key is the decryption key for the file data.


from ecdsa import SigningKey, SECP256k1

def create_public_key(private_key_hex):
    private_key_bytes = bytes.fromhex(private_key_hex)
    
    signing_key = SigningKey.from_string(private_key_bytes, curve=SECP256k1)
    verifying_key = signing_key.get_verifying_key()
    
    public_key_bytes = b'\x04' + verifying_key.to_string()
    public_key_hex = public_key_bytes.hex()
    
    return public_key_hex
                

4. Generate Address

Finally, we generate an address from the public key. This address is the folder name which contains the file's metadata (name, chunk list, note, etc.). The chunk list contains seeds that are used to decrypt each chunk of the file.


import hashlib
import base58

def generate_address(public_key_hex):
    public_key_bytes = bytes.fromhex(public_key_hex)

    sha256_hash = hashlib.sha256(public_key_bytes).digest()

    ripemd160 = hashlib.new('ripemd160')
    ripemd160.update(sha256_hash)
    ripemd160_hash = ripemd160.digest()

    versioned_payload = b'\x00' + ripemd160_hash

    checksum = hashlib.sha256(hashlib.sha256(versioned_payload).digest()).digest()[:4]

    binary_address = versioned_payload + checksum
    
    address = base58.b58encode(binary_address).decode('utf-8')

    return address