for r, dont use bigint but hex string

This commit is contained in:
callebtc
2022-11-02 23:43:37 +01:00
parent 970748216f
commit ff724bf744
2 changed files with 13 additions and 5 deletions
+5 -3
View File
@@ -21,14 +21,16 @@ async function hashToCurve(secretMessage) {
async function step1Alice(secretMessage) {
const Y = await hashToCurve(secretMessage)
const r = bytesToNumber(nobleSecp256k1.utils.randomPrivateKey())
const rpk = nobleSecp256k1.utils.randomPrivateKey()
const r = bytesToNumber(rpk)
const P = nobleSecp256k1.Point.fromPrivateKey(r)
const B_ = Y.add(P)
return {B_: B_.toHex(true), r}
return {B_: B_.toHex(true), r: nobleSecp256k1.utils.bytesToHex(rpk)}
}
function step3Alice(C_, r, A) {
const rInt = BigInt(r)
// const rInt = BigInt(r)
const rInt = bytesToNumber(r)
const C = C_.subtract(A.multiply(rInt))
return C
}