mirror of
https://github.com/arnaucube/blindsig-client-server-example.git
synced 2026-02-06 18:56:40 +01:00
Loop-test send signature to server to be verified
This commit is contained in:
@@ -4,5 +4,6 @@
|
||||
- Run the nodejs loop script: `node loop-test.js`
|
||||
- This will print on the screen the number of iterations each 100 iterations
|
||||
- And if there is an error verifying a signature, will print all the involved parameters
|
||||
- signature verification is done on the JS side, but also sent to the server to verify it from the Go side
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ async function verify() {
|
||||
verified = blindsecp256k1.verify(m, sig, signerQ);
|
||||
if (!verified) {
|
||||
errCount++;
|
||||
console.log("==verification failed on client==", res.data.verification);
|
||||
|
||||
printPoint("signerR", signerR);
|
||||
printPoint("signerQ", signerQ);
|
||||
console.log("m:", m.toString());
|
||||
@@ -63,6 +65,55 @@ async function verify() {
|
||||
printPoint("sig.f", sig.f);
|
||||
console.log("verify", verified);
|
||||
}
|
||||
|
||||
// send to verify by the go server
|
||||
let data = {
|
||||
m: m.toString(),
|
||||
sig: {
|
||||
S: sig.s.toString(),
|
||||
F: {
|
||||
x: sig.f.affineX.toString(),
|
||||
y: sig.f.affineY.toString()
|
||||
}
|
||||
},
|
||||
q: {
|
||||
x: signerQ.affineX.toString(),
|
||||
y: signerQ.affineY.toString()
|
||||
}
|
||||
};
|
||||
try {
|
||||
let res = await axios.post(apiUrl+'/verify', data);
|
||||
if (!res.data.verification) {
|
||||
errCount++;
|
||||
console.log("==verification failed on server==", res.data.verification);
|
||||
|
||||
printPoint("signerR", signerR);
|
||||
printPoint("signerQ", signerQ);
|
||||
console.log("m:", m.toString());
|
||||
console.log("mBlinded:", mBlinded.toString());
|
||||
console.log(`userSecretData:\n a: ${userSecretData.a.toString()}\n b: ${userSecretData.b.toString()}`);
|
||||
printPoint("userSecretData.f", userSecretData.f);
|
||||
console.log("blinded sig:", blindedSig.toString());
|
||||
console.log("sig.s:", sig.s.toString());
|
||||
printPoint("sig.f", sig.f);
|
||||
console.log("verify", verified);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error.response.data);
|
||||
errCount++;
|
||||
console.log("==verification failed on server==", error.response.data.verification);
|
||||
|
||||
printPoint("signerR", signerR);
|
||||
printPoint("signerQ", signerQ);
|
||||
console.log("m:", m.toString());
|
||||
console.log("mBlinded:", mBlinded.toString());
|
||||
console.log(`userSecretData:\n a: ${userSecretData.a.toString()}\n b: ${userSecretData.b.toString()}`);
|
||||
printPoint("userSecretData.f", userSecretData.f);
|
||||
console.log("blinded sig:", blindedSig.toString());
|
||||
console.log("sig.s:", sig.s.toString());
|
||||
printPoint("sig.f", sig.f);
|
||||
console.log("js verify", verified);
|
||||
}
|
||||
}
|
||||
|
||||
async function iteration() {
|
||||
|
||||
6
client/loop-test/package-lock.json
generated
6
client/loop-test/package-lock.json
generated
@@ -45,9 +45,9 @@
|
||||
"integrity": "sha512-TosM7Yg1Ux0ZCNwwS/tW95r3q9xIZstgsUGKWaez0Cgq8Oy3qia9RGvyG/fbxlQAvigjza1d057QNQLGvYXCeg=="
|
||||
},
|
||||
"blindsecp256k1": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/blindsecp256k1/-/blindsecp256k1-0.0.5.tgz",
|
||||
"integrity": "sha512-P+ahL3AlZY2RvtEUH7W3yidTNfDsu7yUsb2OOorEzsSE0cBovQKyBi+d883CVwbgjcW4mFFmHYgBZ0q+QOz9zQ==",
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/blindsecp256k1/-/blindsecp256k1-0.0.6.tgz",
|
||||
"integrity": "sha512-M+QV0G6h5FIR0eqiRkW3DySMoDoobHkr8Zrcx1kLxuvbpZaBI5NL60LI3c600TaHz4TuEJB2C2BdDWsA6JYl4w==",
|
||||
"requires": {
|
||||
"@ethersproject/keccak256": "5.0.7",
|
||||
"bigi": "^1.4.2",
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"blindsecp256k1": "0.0.5"
|
||||
"blindsecp256k1": "0.0.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,20 @@ async function verify() {
|
||||
console.log("verify", verified);
|
||||
alert("ERROR")
|
||||
}
|
||||
// send to verify by the go server
|
||||
let data = {
|
||||
m: mBlinded.toString(),
|
||||
sig: {
|
||||
s: sig.s.toString(),
|
||||
f: {
|
||||
x: sig.f.affineX.toString(),
|
||||
y: sig.f.affineY.toString()
|
||||
}
|
||||
}
|
||||
};
|
||||
let res = await axios.post(apiUrl+'/blindsign', data);
|
||||
console.log("res", res.data);
|
||||
console.log("ver by server", res.data.verification);
|
||||
}
|
||||
|
||||
async function iteration() {
|
||||
|
||||
Reference in New Issue
Block a user