NAME
Net::BitTorrent::DHT::Security - BEP 42 security extensions for BitTorrent DHT
SYNOPSIS
use Net::BitTorrent::DHT::Security;
my $sec = Net::BitTorrent::DHT::Security->new;
my $id = $sec->generate_node_id("127.0.0.1");
if ($sec->validate_node_id($id, "127.0.0.1")) {
say "Node ID is valid for this IP";
}
DESCRIPTION
This class implements the security extensions defined in BEP 42. It provides methods for generating and validating Node IDs based on the node's IP address to prevent Sybil attacks and routing table poisoning.
CRC32c Implementation
This module includes a pure-Perl implementation of the CRC32c (Castagnoli) polynomial (0x82F63B78), which is required by BEP 42 for Node ID calculation.
METHODS
generate_node_id( $ip, $seed? )
Generates a 20-byte Node ID compliant with BEP 42 for the given IP address. An optional 1-byte seed (0-255) can be provided.
validate_node_id( $id, $ip )
Returns true if the provided Node ID is valid for the given IP address according to the BEP 42 criteria (matching the first 21 bits of the ID).
SEE ALSO
BEP 42: http://www.bittorrent.org/beps/bep_0042.html
AUTHOR
Sanko Robinson <sanko@cpan.org>
COPYRIGHT
Copyright (C) 2008-2026 by Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.