mirror of
https://github.com/arnaucube/blindsecp256k1-js.git
synced 2026-02-07 03:16:43 +01:00
Allowing to decode points from the curve
This commit is contained in:
13
src/index.ts
13
src/index.ts
@@ -15,6 +15,11 @@ export const ecParams = { G, n }
|
||||
export type UserSecretData = { a: BigNumber, b: BigNumber, f: Point }
|
||||
export type UnblindedSignature = { s: BigNumber, f: Point }
|
||||
|
||||
export function messageToBigNumber(message: string) {
|
||||
const msg = Buffer.from(message, 'utf8')
|
||||
return new BigNumber(msg)
|
||||
}
|
||||
|
||||
export function hashBigNumber(m: BigNumber) {
|
||||
const mHex = m.toString(16)
|
||||
|
||||
@@ -24,10 +29,14 @@ export function hashBigNumber(m: BigNumber) {
|
||||
return keccak256('0x0' + mHex).slice(2) // Trim 0x
|
||||
}
|
||||
|
||||
export function bigNumberFromString(s: string) {
|
||||
export function stringToBigNumber(s: string) {
|
||||
return new BigNumber(s)
|
||||
}
|
||||
|
||||
export function decodePoint(hexPoint: string): Point {
|
||||
return secp256k1.keyFromPublic(Buffer.from(hexPoint, "hex")).getPublic()
|
||||
}
|
||||
|
||||
function random(bytes: number) {
|
||||
let k: BigNumber
|
||||
do {
|
||||
@@ -96,7 +105,7 @@ export function verify(m: BigNumber, s: UnblindedSignature, q: Point) {
|
||||
const sG = G.mul(s.s)
|
||||
|
||||
const hHex = hashBigNumber(m)
|
||||
|
||||
|
||||
const h = new BigNumber(Buffer.from(hHex, "hex"))
|
||||
|
||||
const rx = s.f.getX().mod(n)
|
||||
|
||||
Reference in New Issue
Block a user