mirror of
https://github.com/Mach-34/the-word.git
synced 2026-01-10 13:48:00 -05:00
fix should work
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npx tsc && cp -r ./artifacts dest/artifacts",
|
||||
"test": "NODE_NO_WARNINGS=1 ts-node --esm ./src/test.ts",
|
||||
"local": "NODE_NO_WARNINGS=1 ts-node --esm ./src/cli.ts",
|
||||
"play": "./scripts/the-word.sh",
|
||||
"circuits:crs": "./scripts/crs.sh",
|
||||
"circuits:compile": "./scripts/compile-circuit.sh"
|
||||
|
||||
@@ -140,7 +140,7 @@ async function createRound(phrase: string, username: string, hint: string) {
|
||||
|
||||
console.log("=====================================")
|
||||
if (res.status != 201) {
|
||||
console.log(`${chalk.red("ERROR: ")} ${await res.text()}}`);
|
||||
console.log(`${chalk.red("ERROR: ")} ${await res.text()}`);
|
||||
} else {
|
||||
// write proof to file
|
||||
const pwd = execSync('pwd').toString().replace(/(\r\n|\n|\r)/gm, "");
|
||||
@@ -244,7 +244,6 @@ async function whisper(round: string, phrase: string, username: string) {
|
||||
|
||||
// generate proof
|
||||
const { proof, publicSignals } = await engine.prove(input);
|
||||
const hash = `0x${BigInt(publicSignals[0]).toString(16)}`;
|
||||
|
||||
// send to server
|
||||
const URL = `${API_URL}/whisper`;
|
||||
@@ -253,7 +252,6 @@ async function whisper(round: string, phrase: string, username: string) {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
round,
|
||||
message: hash,
|
||||
username,
|
||||
proof,
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ export async function createRound(req: Request, res: Response) {
|
||||
/// DISABLE THIS ENDPOINT UNTIL FURTHER NOTICE ///
|
||||
return res.status(403).send("Creation endpoint is currently disabled");
|
||||
//////////////////////////////////////////////////
|
||||
// // message is the commitment to the round secret
|
||||
// message is the commitment to the round secret
|
||||
// const { message, username, proof, hint } = req.body;
|
||||
|
||||
// // convert the username into a bigint
|
||||
@@ -92,7 +92,7 @@ export async function getRound(req: Request, res: Response) {
|
||||
*/
|
||||
export async function whisper(req: Request, res: Response) {
|
||||
// get round, address, hash, and proof of knowledge of hash preimage
|
||||
const { message, username, proof, round, address } = req.body;
|
||||
const { username, proof, round } = req.body;
|
||||
|
||||
// attempt to retrieve the round from the database
|
||||
const roundData = await Round.findOne({ round })
|
||||
@@ -106,11 +106,14 @@ export async function whisper(req: Request, res: Response) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get commitment from stored round
|
||||
let commitment = roundData.commitment;
|
||||
|
||||
// convert the username into a bigint
|
||||
const usernameEncoded = usernameToBigint(username);
|
||||
const usernameEncoded = `0x${BigInt(usernameToBigint(username)).toString(16)}`;
|
||||
|
||||
// verify proof of knowledge of secret
|
||||
const verified = await groth16.verify(vkey, [message, usernameEncoded], proof);
|
||||
const verified = await groth16.verify(vkey, [commitment, usernameEncoded], proof);
|
||||
if (!verified) {
|
||||
res.status(400).send("Invalid proof");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user