0.0.9-alpha.0 • Published 1 year ago

@next-wallet/sss v0.0.9-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Device Authentication Library with Shamir's Secret Sharing

A library for managing device authentication using Shamir's Secret Sharing.

Features

  • Generate New Shares: Create new shares from a secret.
  • Recover Secret: Recover the original secret from shares.
  • Update Shares: Update and generate new shares from existing shares.
  • Destroy Old Shares: Securely destroy old shares.
  • Expand Shares: Expand the number of shares while maintaining the threshold.

Installation

Install the library using npm:

npm install @next-wallet/sss

Usage

Importing the Library

First, import the library in your project:

import * as authLib from '@your-scope/your-package';

Generating New Shares

Generate new shares from a secret with a specified number of shares and threshold:

const secret = new Uint8Array([
  /* your secret data */
]);
const shares = await authLib.generateNewShares(secret, 3, 2);
console.log('Generated Shares:', shares);

Recovering the Secret

Recover the original secret from the shares:

const recoveredSecret = await authLib.recoverSecret(shares);
console.log('Recovered Secret:', recoveredSecret);

Updating Shares

Update and generate new shares from existing shares:

const newShares = await authLib.updateShares(shares, 3, 2);
console.log('New Shares:', newShares);

Expanding Shares

Expand the number of shares while maintaining the threshold:

const expandedShares = await authLib.expandShares(shares, 5, 2);
console.log('Expanded Shares:', expandedShares);

API Reference

generateNewShares(secret: Uint8Array, shares: number = 3, threshold: number = 2): Promise<Uint8Array[]>

Generates new shares from a secret.

  • Parameters:

    • secret: The secret to be shared (Uint8Array).
    • shares: The number of shares to generate (default is 3).
    • threshold: The minimum number of shares required to recover the secret (default is 2).
  • Returns: A promise that resolves to an array of shares (Uint8Array[]).

recoverSecret(shares: Uint8Array[]): Promise<Uint8Array>

Recovers the original secret from the shares.

  • Parameters:

    • shares: An array of shares (Uint8Array[]).
  • Returns: A promise that resolves to the recovered secret (Uint8Array).

updateShares(oldShares: Uint8Array[], shares: number = 3, threshold: number = 2): Promise<Uint8Array[]>

Updates and generates new shares from existing shares.

  • Parameters:

    • oldShares: An array of old shares (Uint8Array[]).
    • shares: The number of new shares to generate (default is 3).
    • threshold: The minimum number of shares required to recover the secret (default is 2).
  • Returns: A promise that resolves to an array of new shares (Uint8Array[]).

expandShares(oldShares: Uint8Array[], newShareCount: number, threshold: number): Promise<Uint8Array[]>

Expands the number of shares while maintaining the threshold.

  • Parameters:

    • oldShares: An array of old shares (Uint8Array[]).
    • newShareCount: The new total number of shares.
    • threshold: The minimum number of shares required to recover the secret.
  • Returns: A promise that resolves to an array of combined old and new shares (Uint8Array[]).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on how to get started.

Acknowledgements

This library uses Shamir's Secret Sharing algorithm for secure secret management.

0.0.1-beta.1

1 year ago

0.0.1-beta.0

1 year ago

0.0.9-alpha.0

1 year ago

0.0.5-alpha.0

1 year ago

0.0.3-alpha.0

1 year ago

0.0.4-alpha.0

1 year ago

0.0.2-alpha.0

1 year ago

0.0.1-alpha.0

1 year ago

0.0.1

1 year ago