Skip to content

Instantly share code, notes, and snippets.

@reisepass
Created November 26, 2023 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reisepass/7a55cff366bef897aed4ef69b24de9c9 to your computer and use it in GitHub Desktop.
Save reisepass/7a55cff366bef897aed4ef69b24de9c9 to your computer and use it in GitHub Desktop.
web5 load external private key
const passphrase = "passphrase typed in from user interface"
const private_key_restored_from_db = "uint8array_base64_encoded_on_db"
const public_key_restored_from_db = "uint8array_base64_encoded_on_db_pub"
let appData = new AppDataVault({
store: new LevelStore('DATA/AGENT/APPDATA')
});
const options={
algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' },
extractable : true,
keyUsages : ['sign', 'verify']
};
const { algorithm, extractable, keyUsages } = options;
cryptoKeyPair = {
privateKey : new CryptoKey(algorithm, extractable, private_key_restored_from_db, 'private', keyUsages),
publicKey : new CryptoKey(algorithm, true, public_key_restored_from_db, 'public', keyUsages)
};
await appData.initialize({
passphrase : passphrase,
keyPair : cryptoKeyPair,
});
const { web5, did: aliceDid } = await Web5.connect({appData:appData});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment