Close Menu
    Facebook LinkedIn YouTube WhatsApp X (Twitter) Pinterest
    Trending
    • Life-extending drug trial for senior dogs expands
    • Bill Atkinson, Macintosh Pioneer and Inventor of Hypercard, Dies at 74
    • Best Internet Providers in New Hampshire
    • The Rise of AI Girlfriends You Don’t Have to Sign Up For
    • The most incredible practical movie stunts ever filmed
    • Tech Up Your Sourdough With These Upper-Crust Baking Gadgets
    • Resident Evil Requiem Revealed, but Where’s Leon Kennedy?
    • What Happens When You Remove the Filters from AI Love Generators?
    Facebook LinkedIn WhatsApp
    Times FeaturedTimes Featured
    Sunday, June 8
    • Home
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    • More
      • AI
      • Robotics
      • Industries
      • Global
    Times FeaturedTimes Featured
    Home»Artificial Intelligence»How to Share a Secret: Shamir’s Secret Sharing | by Jimin Kang | Jan, 2025
    Artificial Intelligence

    How to Share a Secret: Shamir’s Secret Sharing | by Jimin Kang | Jan, 2025

    Editor Times FeaturedBy Editor Times FeaturedJanuary 31, 2025No Comments2 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr WhatsApp Email
    Share
    Facebook Twitter LinkedIn Pinterest Telegram Email WhatsApp Copy Link


    import random # in observe, this ought to be cryptographically safe
    import numpy as np
    from numpy.polynomial import polynomial as P
    from prompt_inputs import accept_scheme_parameters, prompt_pooled_parties

    # prime quantity to outline the finite discipline the place coefficients might be sampled from
    # in observe, FIELD_SIZE > max(n, ok)
    FIELD_SIZE = 65521

    def generate_polynomial(d, ok):
    “””
    Parameters:
    d: diploma of polynomial to be generated
    ok: secret to outline polynomial y-intercept
    Returns:
    poly: vector of polynomial coefficients & intercept
    ordered from intercept time period to largest diploma time period i.e. [k, a_{1}, a_{2},…, a_{t-1}]
    “””
    # generate random coeffcients from {0,…,p-1}
    poly = [random.randint(0, FIELD_SIZE-1) for _ in range(d)]

    # coefficient of largest diploma time period should be non-zero
    poly[-1] = random.randint(1, FIELD_SIZE-1)

    # place secret at y-intercept i.e. p(0) = ok
    poly.insert(0, ok)

    return poly

    def compute_shares(poly, n):
    “””
    Parameters:
    coeff: polynomial coefficients ordered from intercept time period to largest diploma time period i.e. [k, a_{1}, a_{2},…, a_{t-1}]
    n: variety of events to distribute secret shares to
    Returns:
    shares: vector of computed shares
    ordered by ascending order of celebration index i.e. [s_{1}, s_{2},…, s_{n}]
    “””
    # consider polynomial at x in {1, 2,…, n}
    x = np.arange(1, n + 1, 1)

    # Generate the Vandermonde matrix
    vandermonde = P.polyvander(x=x, deg=len(poly)-1)

    # shares = vandermonde * poly
    shares = vandermonde @ poly

    return shares

    def reconstruct_secret(shares, indices):
    “””
    Parameters:
    shares: pooled share values
    indices: events equivalent to pooled share values
    Returns:
    secret & vector containing polynomial coefficients and secret
    “””
    # Vandermonde matrix for pooled events
    vandermonde = P.polyvander(x=indices, deg=len(indices)-1)

    # coeff = inv(Vandermonde) * shares
    poly = np.linalg.inv(vandermonde) @ np.array(shares)

    # rounding to deal w/ floating pt. precision errors: wrapping integer lists into numpy arrays might promote integers into floats
    # polynomial coefficients are integers in {0,…,p-1}
    poly = [float(poly[0])] + [round(x) for x in poly[1:]]

    print(f”Reconstructed Secret: {poly[0]}”)
    print(f”Reconstructed Polynomial: {poly}”)

    def display_scheme_info(ok, poly, shares):
    “””
    Show secret (ok), polynomial, and shares for the collaborating events within the (t, n) secret sharing scheme.
    “””
    print(f”Secret: {ok}”)
    print(f”Polynomial: {poly}”)
    print(“Shares:”)
    for i, share in enumerate(shares):
    print(f” Occasion {i+1}: {share}”)

    def important():
    # outline scheme & compute/distribute shares
    t, n, ok = accept_scheme_parameters()
    poly = generate_polynomial(t-1, ok)
    shares = compute_shares(poly, n)

    display_scheme_info(ok, poly, shares)

    # immediate for shares to pool
    pooled_parties = prompt_pooled_parties(t, n)
    pooled_shares = [shares[i-1] for i in pooled_parties]

    # reconstruct secret from pooled shares
    reconstruct_secret(pooled_shares, pooled_parties)



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Editor Times Featured
    • Website

    Related Posts

    The Rise of AI Girlfriends You Don’t Have to Sign Up For

    June 7, 2025

    What Happens When You Remove the Filters from AI Love Generators?

    June 7, 2025

    7 AI Hentai Girlfriend Chat Websites No Filter

    June 7, 2025

    How AI Girlfriend Chatbots Create Unique Interactions

    June 7, 2025

    How I Automated My Machine Learning Workflow with Just 10 Lines of Python

    June 7, 2025

    Prescriptive Modeling Unpacked: A Complete Guide to Intervention With Bayesian Modeling.

    June 7, 2025

    Comments are closed.

    Editors Picks

    Life-extending drug trial for senior dogs expands

    June 7, 2025

    Bill Atkinson, Macintosh Pioneer and Inventor of Hypercard, Dies at 74

    June 7, 2025

    Best Internet Providers in New Hampshire

    June 7, 2025

    The Rise of AI Girlfriends You Don’t Have to Sign Up For

    June 7, 2025
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    About Us
    About Us

    Welcome to Times Featured, an AI-driven entrepreneurship growth engine that is transforming the future of work, bridging the digital divide and encouraging younger community inclusion in the 4th Industrial Revolution, and nurturing new market leaders.

    Empowering the growth of profiles, leaders, entrepreneurs businesses, and startups on international landscape.

    Asia-Middle East-Europe-North America-Australia-Africa

    Facebook LinkedIn WhatsApp
    Featured Picks

    Nice Rocc Palm Cooling Device Review: Pricey, Effective Palm Cooling

    June 1, 2025

    B&H Photo Promo Codes and Deals for February 2025

    February 1, 2025

    Where to Find Prescription Discounts on Heart Medication and More

    February 3, 2025
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    Copyright © 2024 Timesfeatured.com IP Limited. All Rights.
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us

    Type above and press Enter to search. Press Esc to cancel.