Skip to content

Commit

Permalink
comment regarding the salt generator
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht committed Oct 5, 2023
1 parent 59a2a50 commit 4881520
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/createDecoys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import { Hasher } from './sdJwt'
import { OrPromise } from './types'

/**
* Key should not be used to generate the salt as it needs to be unique. It is used for testing here
* Function which returns a salt generated by a CSPRNG.
*
* Recommended size is 128 bits (i.e. 16 bytes).
*
* Salts will not be seeded and a new one will be used for each claim.
*
* @example
*
* Node.js: `crypto.randomBytes(128 / 8)`
*
* React Native: `expo-standard-web-crypto`
*
* Browser: `crypto.getRandomValues(new Uint8Array(128 / 8))`
*/
export type SaltGenerator = () => OrPromise<string>

Expand All @@ -16,7 +28,7 @@ const createDecoy = async (saltGenerator: SaltGenerator, hasher: Hasher) => {
export const createDecoys = async (
count: number,
saltGenerator: SaltGenerator,
hasher: Hasher,
hasher: Hasher
) => {
const decoys: Array<string> = []
for (let i = 0; i < count; i++) {
Expand Down

0 comments on commit 4881520

Please sign in to comment.