Three round m-of-m key aggregation for Stellar using the MuSig signature scheme
npm install @futuretense/stellar-musig
import * as musig from '@futuretense/stellar-musig';
const keys1 = StellarSdk.Keypair.random();
const keys2 = StellarSdk.Keypair.random();
const config = new musig.Config([
keys1.publicKey(),
keys2.publicKey()
]);
const publicKey = config.publicKey;
const transaction = new StellarSdk.TransactionBuilder(...)
...
.build();
const session1 = new musig.Session(config, keys1, {tx: transaction});
const session2 = new musig.Session(config, keys2, {tx: transaction});
const c1 = session1.getLocalCommitment();
const c2 = session2.getLocalCommitment();
session1.setRemoteCommitment(...c2);
session2.setRemoteCommitment(...c1);
const n1 = session1.getLocalNonce();
const n2 = session2.getLocalNonce();
session1.setRemoteNonce(...n2);
session2.setRemoteNonce(...n1);
const s1 = session1.getLocalSignature();
const s2 = session2.getLocalSignature();
session1.setRemoteSignature(...s2);
session2.setRemoteSignature(...s1);
const signature = session1.aggregateSignature;
const vk = StellarSdk.Keypair.fromPublicKey(publicKey);
console.log(vk.verify(message, signature));
Copyright © 2019 Future Tense, LLC