monorepo 버전 준비
## @strpc 기존 RPC를 package화 ### @strpc/express express의 middleware + router 결함 ## @sammo 게임 전체 - server, client - gateway_server, gateway_client
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { ECDSA_sign_bson, ECDSA_verify_bson } from "./ECDSA.js";
|
||||
import { genKey } from "./ECKey.js";
|
||||
import { randomBytes } from "./utils.js";
|
||||
test('basic sign', async () => {
|
||||
const [signKey, verifyKey] = await genKey();
|
||||
|
||||
const misVerifyKey = Buffer.alloc(verifyKey.length);
|
||||
verifyKey.copy(misVerifyKey);
|
||||
misVerifyKey[misVerifyKey.length - 2] ^= 1; //1bit
|
||||
|
||||
const msg = randomBytes(100);
|
||||
const misMsg = Buffer.alloc(msg.length);
|
||||
msg.copy(misMsg);
|
||||
misMsg[1] ^= 1;
|
||||
|
||||
const signature = await ECDSA_sign_bson(signKey, msg);
|
||||
expect(signature.length).toEqual(96);
|
||||
|
||||
const misSignature = Buffer.alloc(signature.length);
|
||||
signature.copy(misSignature);
|
||||
misSignature[misSignature.length - 2] ^= 3;
|
||||
|
||||
const t0P = ECDSA_verify_bson(verifyKey, msg, signature);
|
||||
const f1P = ECDSA_verify_bson(misVerifyKey, msg, signature);
|
||||
const f2P = ECDSA_verify_bson(verifyKey, misMsg, signature);
|
||||
const f3P = ECDSA_verify_bson(verifyKey, msg, misSignature);
|
||||
|
||||
expect(await t0P).toEqual(true);
|
||||
expect(await f1P).toEqual(false);
|
||||
expect(await f2P).toEqual(false);
|
||||
expect(await f3P).toEqual(false);
|
||||
})
|
||||
Reference in New Issue
Block a user