Skip to content

Instantly share code, notes, and snippets.

@andyraddatz
Created October 15, 2021 22:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save andyraddatz/6f90c1c567d072d33ec4c530daf528d6 to your computer and use it in GitHub Desktop.
BlueSky - How to verify ownership of accounts and content across 3 platforms
// Node.js script
// npm install noble-bls12-381 - https://github.com/paulmillr/noble-bls12-381
const bls = require('noble-bls12-381');
const util = require('util');
const txtEncoder = new util.TextEncoder();
function arrayToHex(array) {
return Array.from(array)
.map(c => c.toString(16).padStart(2, "0"))
.join("");
}
// each platform gets its own unique public key
const uniquePubKeyIPFS = '8b3bbfb646108ed73231a31090886428be7c4c25a810fcbce9a9d2f23edb248ca3c5b40dfc13fb9e01118bbcc2a39814';
const uniquePubKeyStretchConsulting = 'b36524cd77a0c3f5da77c6c71b66b8d5f7a23c863a137484969c966fd3e23e2fc81accb9a2c567a1588308f86c61575c';
const uniquePubKeyTwitter = '861c6d822680b8ff5c0ff044a5427973e7afe7adde30846679b1bc2b5fc5561338e20a55bd7c051ac353ab868f361ce2';
// ... any number of additional platforms
// identical content is posted to all platforms
const content = 'hello bluesky';
const contentByteArray = txtEncoder.encode(content);
const contentHexString = arrayToHex(contentByteArray);
// identical signature accompanies the content on each platform
const aggSignature = '93fee4ac27aa19c61d636280d6061fea426f04a537effe9072ac3fcb4205c86430f3e4cd4aa9db58d28896d237705bd3117df4b8819907f7855af051be9e7cdd363656e7efc9e5830dfc40964e2b0882d85cd5b0c305750e94b5ef0706ed1860';
// using BLS public key aggregation from ANY NUMBER OF PLATFORMS
const aggPubKey = bls.aggregatePublicKeys([uniquePubKeyIPFS, uniquePubKeyStretchConsulting, uniquePubKeyTwitter]);
// ...we can verify that ALL private keys were used to sign content
(async() => {
const isVerified = await bls.verify(aggSignature, contentHexString, aggPubKey);
console.log('Verified:', isVerified)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment