Skip to content

Commit

Permalink
[lightspark-cli] add remote signing support (#6203)
Browse files Browse the repository at this point in the history
- adds option to select node for operations that use a node
- updates wasm packed lightspark_crypto lib
- uses loadNodeSigningKey to unlock/provide credentials for both OSK and
remote signing nodes

Depends on: lightsparkdev/webdev#6089

GitOrigin-RevId: 3881892bcb99c19779fcacac3dadd97959ab75ba
  • Loading branch information
bsiaotickchong authored and Lightspark Eng committed Sep 19, 2023
1 parent dcbc054 commit a0fc130
Show file tree
Hide file tree
Showing 10 changed files with 498 additions and 102 deletions.
7 changes: 7 additions & 0 deletions apps/examples/streaming-wallet-extension/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ module.exports = {
configure: (webpackConfig, { env, paths }) => {
return {
...webpackConfig,
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
fallback: {
path: false,
fs: false,
}
},
entry: {
main: [
env === "development" &&
Expand Down
73 changes: 60 additions & 13 deletions packages/lightspark-cli/lightspark_crypto/lightspark_crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@
/* eslint-disable */
/**
*/
export enum Network {
Bitcoin = 0,
Testnet = 1,
Regtest = 2,
}
/**
*/
export class InvoiceSignature {
free(): void;
/**
* @returns {Uint8Array}
*/
get_signature(): Uint8Array;
/**
* @returns {number}
*/
get_recovery_id(): number;
}
/**
*/
export class LightsparkSigner {
free(): void;
/**
* @param {Seed} seed
* @param {number} network
* @returns {LightsparkSigner}
*/
static new(seed: Seed): LightsparkSigner;
static new(seed: Seed, network: number): LightsparkSigner;
/**
* @param {Uint8Array} seed
* @param {number} network
* @returns {LightsparkSigner}
*/
static from_bytes(seed: Uint8Array): LightsparkSigner;
static from_bytes(seed: Uint8Array, network: number): LightsparkSigner;
/**
* @returns {string}
*/
Expand All @@ -26,33 +48,58 @@ export class LightsparkSigner {
/**
* @param {Uint8Array} message
* @param {string} derivation_path
* @param {boolean} is_raw
* @param {Uint8Array | undefined} add_tweak
* @param {Uint8Array | undefined} mul_tweak
* @returns {Uint8Array}
*/
derive_key_and_sign(message: Uint8Array, derivation_path: string, add_tweak?: Uint8Array, mul_tweak?: Uint8Array): Uint8Array;
derive_key_and_sign(message: Uint8Array, derivation_path: string, is_raw: boolean, add_tweak?: Uint8Array, mul_tweak?: Uint8Array): Uint8Array;
/**
* @param {string} public_key
* @param {Uint8Array} public_key
* @returns {Uint8Array}
*/
ecdh(public_key: string): Uint8Array;
ecdh(public_key: Uint8Array): Uint8Array;
/**
* @param {string} unsigned_invoice
* @param {string} derivation_path
* @param {bigint} per_commitment_point_idx
* @returns {Uint8Array}
*/
sign_invoice(unsigned_invoice: string): Uint8Array;
get_per_commitment_point(derivation_path: string, per_commitment_point_idx: bigint): Uint8Array;
/**
* @param {bigint} channel
* @param {string} derivation_path
* @param {bigint} per_commitment_point_idx
* @returns {Uint8Array}
*/
get_per_commitment_point(channel: bigint, per_commitment_point_idx: bigint): Uint8Array;
release_per_commitment_secret(derivation_path: string, per_commitment_point_idx: bigint): Uint8Array;
/**
* @param {bigint} channel
* @param {bigint} per_commitment_point_idx
* @returns {Uint8Array}
*/
build_commitment_secret(channel: bigint, per_commitment_point_idx: bigint): Uint8Array;
generate_preimage_nonce(): Uint8Array;
/**
* @param {Uint8Array} nonce
* @returns {Uint8Array}
*/
generate_preimage(nonce: Uint8Array): Uint8Array;
/**
* @param {Uint8Array} nonce
* @returns {Uint8Array}
*/
generate_preimage_hash(nonce: Uint8Array): Uint8Array;
/**
* @param {string} derivation_path
* @returns {string}
*/
derive_private_key(derivation_path: string): string;
/**
* @param {string} unsigned_invoice
* @returns {InvoiceSignature}
*/
sign_invoice_wasm(unsigned_invoice: string): InvoiceSignature;
/**
* @param {Uint8Array} invoice_hash
* @returns {InvoiceSignature}
*/
sign_invoice_hash_wasm(invoice_hash: Uint8Array): InvoiceSignature;
}
/**
*/
Expand All @@ -61,7 +108,7 @@ export class Mnemonic {
/**
* @returns {Mnemonic}
*/
static new(): Mnemonic;
static random(): Mnemonic;
/**
* @param {Uint8Array} entropy
* @returns {Mnemonic}
Expand Down
Loading

0 comments on commit a0fc130

Please sign in to comment.