@dstanesc/o-o-o-o-o-o-o
Version:
O-O-O-O-O-O-O is a collection of content addressed persistent data structures
26 lines • 968 B
JavaScript
const signerFactory = ({ subtle, privateKey, publicKey, }) => {
const sign = async (root) => {
const buffer = await subtle.sign({
name: 'RSA-PSS',
saltLength: 32,
}, privateKey, root.bytes);
return new Uint8Array(buffer);
};
const exportPublicKey = async () => {
const exported = await subtle.exportKey('jwk', publicKey);
return JSON.stringify(exported);
};
return { sign, exportPublicKey };
};
const verify = async ({ subtle, publicKey, root, signature, }) => {
return await subtle.verify({
name: 'RSA-PSS',
saltLength: 32,
}, publicKey, signature, root.bytes);
};
const importPublicKey = async ({ subtle, key: keyString, }) => {
const key = JSON.parse(keyString);
return await subtle.importKey('jwk', key, { name: 'RSA-PSS', hash: 'SHA-256' }, true, ['verify']);
};
export { signerFactory, verify, importPublicKey };
//# sourceMappingURL=trust.js.map