Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
5a27c1f8
Commit
5a27c1f8
authored
5 years ago
by
Sasha Ilieva
Browse files
Options
Downloads
Patches
Plain Diff
Add secrets.js
parent
ae78d8ef
No related branches found
No related tags found
1 merge request
!88
908 account recovery ability to add contacts to trusted contacts list for account recovery
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
javascript/src/utilities/secrets.js
+30
-0
30 additions, 0 deletions
javascript/src/utilities/secrets.js
with
30 additions
and
0 deletions
javascript/src/utilities/secrets.js
0 → 100644
+
30
−
0
View file @
5a27c1f8
import
{
secrets
}
from
"
secrets.js-grempe
"
;
export
/**
* Function generates a random bits length string, and output it in hexadecimal format
*
* @param {number} bits
*/
const
generateRecoveryKey
=
bits
=>
secrets
.
random
(
bits
);
/**
* Divide a secret expressed in hexadecimal form into numShares number of shares, requiring that threshold number of shares be present for reconstructing the secret
*
* @param {string} secret
* @param {number} numShares
* @param {number} threshold
* @param {number} [padLength=128]
*/
export
const
divideSecretToShares
=
(
secret
,
numShares
,
threshold
,
padLength
=
128
)
=>
secrets
.
share
(
secret
,
numShares
,
threshold
,
padLength
);
/**
* Reconstructs a secret from shares
*
* @param {array} shares
*/
export
const
combineSecret
=
shares
=>
secrets
.
combine
(
shares
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment