mirror of
https://github.com/lnbits/lnbits.git
synced 2025-05-28 12:19:54 +02:00
for r, dont use bigint but hex string
This commit is contained in:
parent
67d0249d19
commit
c0f0421f8a
@ -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
|
||||
}
|
||||
|
@ -1060,7 +1060,11 @@ page_container %}
|
||||
promiseToProof: function (id, amount, C_hex, secret, r) {
|
||||
const C_ = nobleSecp256k1.Point.fromHex(C_hex)
|
||||
const A = this.keys[amount]
|
||||
const C = step3Alice(C_, r, nobleSecp256k1.Point.fromHex(A))
|
||||
const C = step3Alice(
|
||||
C_,
|
||||
nobleSecp256k1.utils.hexToBytes(r),
|
||||
nobleSecp256k1.Point.fromHex(A)
|
||||
)
|
||||
return {
|
||||
id,
|
||||
amount,
|
||||
@ -1226,7 +1230,9 @@ page_container %}
|
||||
const rs = []
|
||||
for (let i = 0; i < amounts.length; i++) {
|
||||
const secret = nobleSecp256k1.utils.randomBytes(32)
|
||||
// const secret = nobleSecp256k1.utils.hexToBytes('0000000000000000000000000000000000000000000000000000000000000003')
|
||||
// const secret = nobleSecp256k1.utils.hexToBytes(
|
||||
// '0000000000000000000000000000000000000000000000000000000000000000'
|
||||
// )
|
||||
// todo: base64Url
|
||||
const encodedSecret = uint8ToBase64.encode(secret)
|
||||
secrets.push(encodedSecret)
|
||||
|
Loading…
x
Reference in New Issue
Block a user