You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tests.rs
    path of file: ./repos/ckb/network/src/services/dns_seeding
    
    the code of the file until where you have to start completion: use ckb_hash::blake2b_256;
use p2p::secio::PeerId;
use rand::Rng;
use secp256k1::{
    Message, {PublicKey, SecretKey},
};
use std::{
    net::IpAddr,
    time::{SystemTime, UNIX_EPOCH},
};

use crate::services::dns_seeding::seed_record::{SeedRecord, SeedRecordError, SECP256K1, SEP};

struct Generator;

impl Generator {
    fn random_keypair() -> (SecretKey, PublicKey) {
        let secret_key = Self::random_secret_key();
        let pubkey = PublicKey::from_secret_key(&*SECP256K1, &secret_key);
        (secret_key, pubkey)
    }

    fn random_secret_key() -> SecretKey {
        let mut seed = vec![0; 32];
  
    
    fn encode(&self, privkey: &SecretKey) -> Result<String, SeedRecordError> {
        if PublicKey::from_secret_key(&SECP256K1, privkey) != self.pubkey {
            return Err(SeedRecordError::KeyNotMatch);
        }

        let data = Self::data_to_sign(self.ip, self.port, self.peer_id.as_ref(), self.valid_until);
        let hash = blake2b_256(&data);
        let message = Message::from_slice(&hash).expect("create message error");

        let signature = SECP256K1.sign_ecdsa_recoverable(&message, privkey);
        let (recid, signed_data) = signature.serialize_compact();
        let mut sig = [0u8; 65];
        sig[0..64].copy_from_slice(&signed_data[0..64]);
        sig[64] = recid.to_i32() as u8;
        let signature_string = bs58::encode(&sig[..]).into_string();
        Ok([data, signature_string].join(&SEP.to_string()))
    }