mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 23:24:22 +01:00
- Add project structure with TypeScript, React, and Vite - Implement nostr authentication using browser extension (NIP-07) - Add NIP-51 compliant bookmark fetching and display - Create minimal UI with login and bookmark components - Integrate applesauce-core and applesauce-react libraries - Add responsive styling with dark/light mode support - Include comprehensive README with setup instructions This is a minimal MVP for a nostr bookmark client that allows users to view their bookmarks according to NIP-51 specification.
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.serializeBlindedMessage = exports.deserializeProof = exports.serializeProof = exports.constructProofFromPromise = exports.unblindSignature = exports.blindMessage = exports.createRandomBlindedMessage = void 0;
|
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
const utils_1 = require("@noble/hashes/utils");
|
|
const utils_js_1 = require("../util/utils.js");
|
|
const index_js_1 = require("../common/index.js");
|
|
function createRandomBlindedMessage() {
|
|
return blindMessage((0, utils_1.randomBytes)(32));
|
|
}
|
|
exports.createRandomBlindedMessage = createRandomBlindedMessage;
|
|
function blindMessage(secret, r) {
|
|
const Y = (0, index_js_1.hashToCurve)(secret);
|
|
if (!r) {
|
|
r = (0, utils_js_1.bytesToNumber)(secp256k1_1.secp256k1.utils.randomPrivateKey());
|
|
}
|
|
const rG = secp256k1_1.secp256k1.ProjectivePoint.BASE.multiply(r);
|
|
const B_ = Y.add(rG);
|
|
return { B_, r, secret };
|
|
}
|
|
exports.blindMessage = blindMessage;
|
|
function unblindSignature(C_, r, A) {
|
|
const C = C_.subtract(A.multiply(r));
|
|
return C;
|
|
}
|
|
exports.unblindSignature = unblindSignature;
|
|
function constructProofFromPromise(promise, r, secret, key) {
|
|
const A = key;
|
|
const C = unblindSignature(promise.C_, r, A);
|
|
const proof = {
|
|
id: promise.id,
|
|
amount: promise.amount,
|
|
secret,
|
|
C
|
|
};
|
|
return proof;
|
|
}
|
|
exports.constructProofFromPromise = constructProofFromPromise;
|
|
const serializeProof = (proof) => {
|
|
return {
|
|
amount: proof.amount,
|
|
C: proof.C.toHex(true),
|
|
id: proof.id,
|
|
secret: new TextDecoder().decode(proof.secret),
|
|
witness: JSON.stringify(proof.witness)
|
|
};
|
|
};
|
|
exports.serializeProof = serializeProof;
|
|
const deserializeProof = (proof) => {
|
|
return {
|
|
amount: proof.amount,
|
|
C: (0, index_js_1.pointFromHex)(proof.C),
|
|
id: proof.id,
|
|
secret: new TextEncoder().encode(proof.secret),
|
|
witness: proof.witness ? JSON.parse(proof.witness) : undefined
|
|
};
|
|
};
|
|
exports.deserializeProof = deserializeProof;
|
|
const serializeBlindedMessage = (bm, amount) => {
|
|
return {
|
|
B_: bm.B_.toHex(true),
|
|
amount: amount
|
|
};
|
|
};
|
|
exports.serializeBlindedMessage = serializeBlindedMessage;
|
|
//# sourceMappingURL=index.js.map
|