@futuretense/stellar-musig
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@futuretense/stellar-musig

Three round m-of-m key aggregation for Stellar using the MuSig signature scheme

Installation

npm install @futuretense/stellar-musig

Usage

Import the library

import * as musig from '@futuretense/stellar-musig';

Set up a configuration object

const keys1 = StellarSdk.Keypair.random();
const keys2 = StellarSdk.Keypair.random();

const config = new musig.Config([
    keys1.publicKey(),
    keys2.publicKey()
]);

const publicKey = config.publicKey;

Create user sessions

const transaction = new StellarSdk.TransactionBuilder(...)
                    ...
                    .build();

const session1 = new musig.Session(config, keys1, {tx: transaction});
const session2 = new musig.Session(config, keys2, {tx: transaction});

Round #1

const c1 = session1.getLocalCommitment();
const c2 = session2.getLocalCommitment();
session1.setRemoteCommitment(...c2);
session2.setRemoteCommitment(...c1);

Round #2

const n1 = session1.getLocalNonce();
const n2 = session2.getLocalNonce();
session1.setRemoteNonce(...n2);
session2.setRemoteNonce(...n1);

Round #3

const s1 = session1.getLocalSignature();
const s2 = session2.getLocalSignature();
session1.setRemoteSignature(...s2);
session2.setRemoteSignature(...s1);

Verify the signature

const signature = session1.aggregateSignature;
const vk = StellarSdk.Keypair.fromPublicKey(publicKey);
console.log(vk.verify(message, signature));

Copyright © 2019 Future Tense, LLC

Readme

Keywords

none

Package Sidebar

Install

npm i @futuretense/stellar-musig

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

3.87 kB

Total Files

4

Last publish

Collaborators

  • johansten