Close Menu
    Facebook LinkedIn YouTube WhatsApp X (Twitter) Pinterest
    Trending
    • A new T-Mobile network for Christians aims to block porn and gender-related content
    • Affordable tiny house starts at just $30K and sleeps two
    • Atlassian’s revenue beat expectations – and its shares popped
    • Elon Musk Seemingly Admits xAI Has Used OpenAI’s Models to Train Its Own
    • OpenAI lawyers claim Shivon Zilis, a longtime Musk employee and mother to four of his children, acted as a covert liaison between him and OpenAI (Wired)
    • Huawei Unveils Car That Can Project Movies With Its Headlights
    • Dreame’s Nebula NEXT 01 JET electric hypercar specs
    • Startup 360: How to travel better and cheaper with AI
    Facebook LinkedIn WhatsApp
    Times FeaturedTimes Featured
    Friday, May 1
    • 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

    Why AI Engineers Are Moving Beyond LangChain to Native Agent Architectures

    May 1, 2026

    How to Study the Monotonicity and Stability of Variables in a Scoring Model using Python

    April 30, 2026

    A Gentle Introduction to Stochastic Programming

    April 30, 2026

    Proxy-Pointer RAG: Multimodal Answers Without Multimodal Embeddings

    April 30, 2026

    DeepSeek’s new AI model is rolling out quietly, not to the Wall Street market shock

    April 30, 2026

    System Design Series: Apache Flink from 10,000 Feet, and Building a Flink-powered Recommendation Engine

    April 30, 2026

    Comments are closed.

    Editors Picks

    A new T-Mobile network for Christians aims to block porn and gender-related content

    May 1, 2026

    Affordable tiny house starts at just $30K and sleeps two

    May 1, 2026

    Atlassian’s revenue beat expectations – and its shares popped

    May 1, 2026

    Elon Musk Seemingly Admits xAI Has Used OpenAI’s Models to Train Its Own

    May 1, 2026
    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

    WrestleMania 41: Don’t Miss Today’s Final Matches

    April 21, 2025

    Inside China’s electric-vehicle-to-humanoid-robot pivot | MIT Technology Review

    February 18, 2025

    Yamaha CrossWave WaveRunner PWC adventure jet boat

    August 21, 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.