install
function install(): void;
Polyfills methods on globalThis.SubtleCrypto
to add support for the Ed25519 algorithm.
Returns
void
Example
import { install } from '@solana/webcrypto-ed25519-polyfill';
// Calling this will shim methods on `SubtleCrypto`, adding Ed25519 support.
install();
// Now you can do this, in environments that do not otherwise support Ed25519.
const keyPair = await crypto.subtle.generateKey({ name: 'Ed25519' }, false, ['sign']);
const publicKeyBytes = await crypto.subtle.exportKey('raw', keyPair.publicKey);
const data = new Uint8Array([1, 2, 3]);
const signature = await crypto.subtle.sign({ name: 'Ed25519' }, keyPair.privateKey, data);
if (await crypto.subtle.verify({ name: 'Ed25519' }, keyPair.publicKey, signature, data)) {
console.log('Data was signed using the private key associated with this public key');
} else {
throw new Error('Signature verification error');
}