feat: 해시 기반 간이 DRBG, 그에 기반한 RandUtil (#208)

기존의 Util 내의 함수는 mt_rand에 기반하고 있어서 일반적으론 충분하지만,
게임 내부에서 랜덤 값을 정교하게 제어하고 싶은 경우에는 적절하지 않았음.

따라서 직접 seed를 제어할 수 있는 난수생성기를 추가.
SHA512(seed || blockIdx) 의 형태로 동작하는 DRBG이며, FIPS 표준을 따르는 RNG는 아니지만 암호학적으로 안전한 형태로 구현함.

PHP, TS 두가지 형태로 구현.

Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/208
Co-authored-by: hide_d <hided62@gmail.com>
Co-committed-by: hide_d <hided62@gmail.com>
This commit is contained in:
2022-03-12 23:53:16 +09:00
parent c220b3d511
commit 0ab485f122
15 changed files with 1620 additions and 4 deletions
+3 -1
View File
@@ -6,7 +6,7 @@
"scripts": {
"test": "npm-run-all test-php-gateway test-ts",
"test-php-gateway": "vendor/bin/phpunit --bootstrap vendor/autoload.php tests",
"test-ts": "node --loader ts-node/esm ./node_modules/.bin/mocha hwe/test-ts/**/*.test.ts",
"test-ts": "mocha",
"build": "webpack",
"buildDev": "webpack --mode=development",
"watch": "webpack watch --mode=development",
@@ -77,6 +77,7 @@
"babel-preset-modern-browsers": "^15.0.2",
"bootswatch": "^5.1.3",
"chai": "^4.3.6",
"chai-bytes": "^0.1.2",
"clean-terminal-webpack-plugin": "^3.0.0",
"css-loader": "^6.6.0",
"cssnano": "^5.0.17",
@@ -95,6 +96,7 @@
"sass-loader": "^12.6.0",
"style-loader": "^3.3.1",
"ts-node": "^10.6.0",
"tsconfig-paths": "^3.13.0",
"typescript": "^4.5.5",
"url-loader": "^4.1.1",
"vue-eslint-parser": "^8.2.0",