PHPackages                             unitpay/shamir - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. unitpay/shamir

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

unitpay/shamir
==============

Shamir PHP implementation

1.0.0(4y ago)242.0k1[1 issues](https://github.com/unitpay/shamir/issues)[1 PRs](https://github.com/unitpay/shamir/pulls)MITPHPPHP ^7.4|^8.0

Since Sep 29Pushed 1y ago3 watchersCompare

[ Source](https://github.com/unitpay/shamir)[ Packagist](https://packagist.org/packages/unitpay/shamir)[ RSS](/packages/unitpay-shamir/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Shamir
======

[](#shamir)

[![Latest Stable Version](https://camo.githubusercontent.com/7d14610b755e06e631ffde118998f8eb24a823da0237411ada398b07ea573be1/68747470733a2f2f706f7365722e707567782e6f72672f756e69747061792f7368616d69722f762f737461626c652e706e67)](https://packagist.org/packages/unitpay/shamir)[![Build status](https://github.com/unitpay/shamir/workflows/build/badge.svg)](https://github.com/unitpay/shamir/actions?query=workflow%3Abuild)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/96f3ceea5d87625ca564bc744e57b8fcd3ad6c0458c03a2721a0c651e781290b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756e69747061792f7368616d69722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/unitpay/shamir/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/98c0af657ac13faa5d2612718a49566cc069e06444b748885daff769fffeeaf6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756e69747061792f7368616d69722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/unitpay/shamir/?branch=master)[![Mutation testing badge](https://camo.githubusercontent.com/933f2aafef9acf3fa7d4cc5c8f51c9f6928d79734acf3f7b14de19d5b27e9445/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246756e69747061792532467368616d69722532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/unitpay/shamir/master)[![static analysis](https://github.com/unitpay/shamir/workflows/static%20analysis/badge.svg)](https://github.com/unitpay/shamir/actions?query=workflow%3A%22static+analysis%22)[![type-coverage](https://camo.githubusercontent.com/b20abf8761570969e4c30d173ba99a03032f781a4bec964a8610e3bad9f0f9a2/68747470733a2f2f73686570686572642e6465762f6769746875622f756e69747061792f7368616d69722f636f7665726167652e737667)](https://shepherd.dev/github/unitpay/shamir)

PHP [Shamir's Secret Sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) implementation. Inspired by hashicorp vault shamir. Compatible with [Simple Shamir's Secret Sharing (s4)](https://github.com/simonfrey/s4).

Requirements
------------

[](#requirements)

- PHP 7.4 or higher.

Installation
------------

[](#installation)

The package could be installed with composer:

```
composer require unitpay/shamir --prefer-dist
```

Usage
-----

[](#usage)

Split secret to parts with threshold

```
$secret = 'Some super secret';
$parts = 5;
$threshold = 3;
$shares = Shamir::split($secret, $parts, $threshold);
```

Reconstruct shares

```
$recoveredSecret = Shamir::reconstruct([$parts[1], $parts[0], $parts[3]]);
```

Testing
-------

[](#testing)

### Unit testing

[](#unit-testing)

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```
./vendor/bin/phpunit
```

### Mutation testing

[](#mutation-testing)

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with [Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:

```
./vendor/bin/roave-infection-static-analysis-plugin
```

### Static analysis

[](#static-analysis)

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```
./vendor/bin/psalm
```

License
-------

[](#license)

It is released under the terms of the MIT License. Please see [`LICENSE`](./LICENSE.md) for more information.

Follow updates
--------------

[](#follow-updates)

[![Twitter](https://camo.githubusercontent.com/d077c362ac639792171af8bc002ee827816733dfc0925f70b557e6d151022226/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d666f6c6c6f772d3144413146323f6c6f676f3d74776974746572266c6f676f436f6c6f723d314441314632266c6162656c436f6c6f723d3535353535353f7374796c653d666c6174)](https://twitter.com/unitpay)[![Telegram](https://camo.githubusercontent.com/4e38dd12535575c39c65bea7119b95e663abb2d1f4e3d669a27bbda07ef603f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d74656c656772616d)](https://t.me/unitpay_talk)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1727d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/802003da90e514914a1912b6c3f7ba6db02b7d70049c9bca67f6b7a14a1296a4?d=identicon)[unitpay](/maintainers/unitpay)

---

Top Contributors

[![AlexGx](https://avatars.githubusercontent.com/u/1571119?v=4)](https://github.com/AlexGx "AlexGx (4 commits)")

---

Tags

shamirshamir-secret-sharing

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/unitpay-shamir/health.svg)

```
[![Health](https://phpackages.com/badges/unitpay-shamir/health.svg)](https://phpackages.com/packages/unitpay-shamir)
```

###  Alternatives

[ianm/syndication

Brings RSS and Atom feeds to Flarum

1518.4k](/packages/ianm-syndication)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
