-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add jest and write frontend test for applySeed
- Loading branch information
1 parent
dc0a675
commit 6f95816
Showing
6 changed files
with
4,305 additions
and
2,680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
transform: {'^.+\\.ts?$': 'ts-jest'}, | ||
testEnvironment: 'node', | ||
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { applySeed, hashToPoint } from "../app/psi"; | ||
const sodium = require("libsodium-wrappers-sumo"); | ||
|
||
beforeAll(async () => { | ||
await sodium.ready; | ||
}); | ||
|
||
describe("testing applySeed", () => { | ||
test("applying secret key should be same as original value", () => { | ||
const password = "TestPass1&"; | ||
|
||
// hash the password | ||
const hashedPassword = hashToPoint(password); | ||
// apply the seed | ||
const [seededPassword, seedInverse] = applySeed(password); | ||
// apply the inverse to the seeded password | ||
const inversedSeededPassword = sodium.crypto_scalarmult_ristretto255( | ||
seedInverse, | ||
seededPassword | ||
); | ||
|
||
// check that the seeded+inversed password is the same as the hashed password | ||
expect(Buffer.compare(inversedSeededPassword, hashedPassword)).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
"**/*.ts", | ||
"**/*.tsx", | ||
".next/types/**/*.ts" | ||
], | ||
, "jest.config.js" ], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
|
Oops, something went wrong.