Skip to main content

MuSig2CreateSession

MuSig2CreateSession (experimental!) creates a new MuSig2 signing session using the local key identified by the key locator. The complete list of all public keys of all signing parties must be provided, including the public key of the local signing key. If nonces of other parties are already known, they can be submitted as well to reduce the number of RPC calls necessary later on.

NOTE: The MuSig2 BIP is not final yet and therefore this API must be considered to be HIGHLY EXPERIMENTAL and subject to change in upcoming releases. Backward compatibility is not guaranteed!

Source: signrpc/signer.proto

gRPC

rpc MuSig2CreateSession (MuSig2SessionRequest) returns (MuSig2SessionResponse);

REST

HTTP MethodPath
POST /v2/signer/musig2/createsession

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'signrpc/signer.proto'], loaderOptions);
const signrpc = grpc.loadPackageDefinition(packageDefinition).signrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new signrpc.Signer(GRPC_HOST, creds);
let request = {
key_loc: <KeyLocator>,
all_signer_pubkeys: <bytes>,
other_signer_public_nonces: <bytes>,
tweaks: <TweakDesc>,
taproot_tweak: <TaprootTweakDesc>,
};
client.muSig2CreateSession(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "session_id": <bytes>,
// "combined_key": <bytes>,
// "taproot_internal_key": <bytes>,
// "local_public_nonces": <bytes>,
// "have_all_nonces": <bool>,
// }

Messages

signrpc.MuSig2SessionRequest

Source: signrpc/signer.proto

FieldgRPC TypeREST TypeREST Placement
key_loc
KeyLocatorobjectbody
all_signer_pubkeys
bytes[]arraybody
other_signer_public_nonces
bytes[]arraybody
tweaks
TweakDesc[]arraybody
taproot_tweak
TaprootTweakDescobjectbody

signrpc.MuSig2SessionResponse

Source: signrpc/signer.proto

FieldgRPC TypeREST Type
session_id
bytesstring
combined_key
bytesstring
taproot_internal_key
bytesstring
local_public_nonces
bytesstring
have_all_nonces
boolboolean

Nested Messages

signrpc.KeyLocator

FieldgRPC TypeREST Type
key_family
int32integer
key_index
int32integer

signrpc.TweakDesc

FieldgRPC TypeREST Type
tweak
bytesstring
is_x_only
boolboolean

signrpc.TaprootTweakDesc

FieldgRPC TypeREST Type
script_root
bytesstring
key_spend_only
boolboolean