()
| 213 | } |
| 214 | |
| 215 | writeRoundTwo() { |
| 216 | if (this.roundTwoSent) throw new Error('Round two already sent'); |
| 217 | if (!this.roundOneSent || !this.roundOneReceived) throw new Error('Round one not completed'); |
| 218 | this.roundTwoSent = true; |
| 219 | |
| 220 | const g_xa = this.g_x1.add(this.g_x3).add(this.g_x4); |
| 221 | const random = new BN(crypto.randomBytes(16)); |
| 222 | const y = random.mul(EC.n).add(new BN(this.secretBytes)); |
| 223 | const x2_s = this.x2.mul(y).umod(EC.n); |
| 224 | const g_s = g_xa.mul(x2_s); |
| 225 | |
| 226 | const zkp = this.generateZKP(g_xa, g_s, x2_s, this.role); |
| 227 | |
| 228 | const result = Buffer.alloc(165); |
| 229 | this.encodePoint(g_s).copy(result, 0); |
| 230 | this.encodeZKP(zkp.v, zkp.r).copy(result, 66); |
| 231 | return result; |
| 232 | } |
| 233 | |
| 234 | readRoundTwo(data) { |
| 235 | if (this.roundTwoReceived) throw new Error('Round two already received'); |
no test coverage detected