Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cy:ci": "cd frontend && npm run cy:run",
"cy:install": "cd frontend && npm run cy:install",
"benchmark": "cd benchmark && npm run benchmark",
"install:all": "npm i --install-links=false && concurrently \"cd shared && npm i --install-links=false\" \"cd frontend && npm i --install-links=false\" \"cd backend && npm i --install-links=false\" \"cd benchmarks && npm i --install-links=false\"",
"install:all": "npm i --install-links=false && concurrently \"cd shared && npm i --install-links=false\" \"cd frontend && npm i --install-links=false\" \"cd backend && npm i --install-links=false\" \"cd benchmark && npm i --install-links=false\"",
"setup": "npm i --install-links=false && cd shared && npm i --install-links=false && npm run build && cd .. && concurrently \"cd frontend && npm i --install-links=false\" \"cd backend && npm i --install-links=false\" \"cd benchmark && npm i --install-links=false\"",
"prune": "npm prune && cd shared && npm prune && cd ../frontend && npm prune && cd ../backend && npm prune",
"prune:deployment": "npm prune --production && cd shared && npm prune --production && cd ../backend && npm prune --production",
Expand Down
30 changes: 14 additions & 16 deletions shared/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"npm": ">=8"
},
"dependencies": {
"@noble/hashes": "^1.2.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"hash.js": "^1.1.7",
"immer": "^9.0.17",
"lodash-es": "^4.17.21",
"rbush": "^3.0.1",
Expand Down
13 changes: 3 additions & 10 deletions shared/src/simulation/utils/randomness.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-bitwise */
import { IsInt, Min, ValidateIf } from 'class-validator';
import hash from 'hash.js';
import { sha256 } from '@noble/hashes/sha256';
import { v4 } from 'uuid';
import { getCreate } from '../../models/utils';
import type { ExerciseState } from '../../state';
Expand Down Expand Up @@ -62,16 +62,9 @@ export function nextInt(
* @param draftState The exercise state where the pseudo random number generator state is stored
* @returns An array of length 32 (specific to sha256) of numbers from 0-255
*/
function advance(draftState: Mutable<ExerciseState>): number[] {
function advance(draftState: Mutable<ExerciseState>): Uint8Array {
const state = draftState.randomState;

const result = hash
.sha256()
.update(draftState.id)
.update(state.counter.toString())
.digest()
.map((b) => b & 0xff);

const result = sha256(`${draftState.id}${state.counter.toString()}`);
state.counter++;
return result;
}