Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Implementation of Shamir's Secret Sharing System

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Makefile.PL
Octocat-spinner-32 README
README
NAME
    Crypt::SSSS - implementation of Shamir's Secret Sharing System.

SYNOPSIS
        use Crypt::SSSS;

        # use (3, 3) scheme
        my $shares = ssss_distribute(
            message => "\x06\x1c\x08",
            k       => 3,
            n       => 3,
            p       => 257);

        # Save shares
        for my $share (1..3) {
            open my $fh, '>', "share${share}.dat";
            print $fh $shares->{$share}->binary;
            close $fh;
        }

        # Reconstruct message
        my $ishares = {};
        for my $share (1..3) {
            open my $fh, '<', "share${share}.dat";
            $ishares->{$share} = do {
                local $/; # slurp!
                <$fh>;
            };
            close $fh;
        }

        print "Original message: ", sprintf '"\x%02x\x%02x\x%02x"',
            unpack('C*', ssss_reconstruct(257, $ishares));

DESCRIPTION
    Implementation of Shamir's Secret Sharing Scheme.

ATTRIBUTES
    Crypt::SSSS implements the following attributes.

  "ssss_distribute"
        my $messages = ssss_distribute(
            message => $message,
            p       => $p,
            k       => $k,
            n       => $n, # By default equals to k
        );

    Distribute $message to $n shares, so that any $k shares would be enough
    to reconstruct the secret. $p is a prime number.

    Returns hashref of Crypt::SSSS::Message.

  "ssss_reconstruct"
        my $secret = ssss_reconstruct($p, $messages);

    Reconstruct message from given $messages. $p is a prime number used to
    distribute message.

AUTHOR
    Sergey Zasenko, "undef@cpan.org".

COPYRIGHT AND LICENSE
    Copyright (C) 2011, Sergey Zasenko.

    This program is free software, you can redistribute it and/or modify it
    under the same terms as Perl 5.10.

Something went wrong with that request. Please try again.